From 351da6c6fb37f42c9cf18b0391ac263579c0ab4f Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 31 Aug 2022 05:47:32 +0000 Subject: [PATCH] CodeGen from PR 19969 in Azure/azure-rest-api-specs Merge b29178dec655cc41f2d2b591d8acf2a9439ee5bf into eec106884e9491f000db50c56539fe4c322603e1 --- sdk/iothub/azure-mgmt-iothub/_meta.json | 10 +- .../azure/mgmt/iothub/_configuration.py | 12 +- .../azure/mgmt/iothub/_iot_hub_client.py | 41 +- .../azure/mgmt/iothub/_serialization.py | 2006 ++++++++ .../azure/mgmt/iothub/aio/_configuration.py | 4 +- .../azure/mgmt/iothub/aio/_iot_hub_client.py | 32 +- .../azure/mgmt/iothub/v2016_02_03/__init__.py | 16 +- .../mgmt/iothub/v2016_02_03/_configuration.py | 49 +- .../iothub/v2016_02_03/_iot_hub_client.py | 25 +- .../mgmt/iothub/v2016_02_03/_metadata.json | 18 +- .../azure/mgmt/iothub/v2016_02_03/_patch.py | 2 +- .../azure/mgmt/iothub/v2016_02_03/_vendor.py | 6 +- .../azure/mgmt/iothub/v2016_02_03/_version.py | 2 +- .../mgmt/iothub/v2016_02_03/aio/__init__.py | 16 +- .../iothub/v2016_02_03/aio/_configuration.py | 51 +- .../iothub/v2016_02_03/aio/_iot_hub_client.py | 25 +- .../mgmt/iothub/v2016_02_03/aio/_patch.py | 2 +- .../v2016_02_03/aio/operations/__init__.py | 8 +- .../_iot_hub_resource_operations.py | 1555 +++--- .../v2016_02_03/aio/operations/_patch.py | 20 + .../iothub/v2016_02_03/models/__init__.py | 106 +- .../models/_iot_hub_client_enums.py | 66 +- .../iothub/v2016_02_03/models/_models_py3.py | 842 ++-- .../mgmt/iothub/v2016_02_03/models/_patch.py | 20 + .../iothub/v2016_02_03/operations/__init__.py | 8 +- .../_iot_hub_resource_operations.py | 2375 +++++---- .../iothub/v2016_02_03/operations/_patch.py | 20 + .../azure/mgmt/iothub/v2017_01_19/__init__.py | 16 +- .../mgmt/iothub/v2017_01_19/_configuration.py | 49 +- .../iothub/v2017_01_19/_iot_hub_client.py | 25 +- .../mgmt/iothub/v2017_01_19/_metadata.json | 18 +- .../azure/mgmt/iothub/v2017_01_19/_patch.py | 2 +- .../azure/mgmt/iothub/v2017_01_19/_vendor.py | 6 +- .../azure/mgmt/iothub/v2017_01_19/_version.py | 2 +- .../mgmt/iothub/v2017_01_19/aio/__init__.py | 16 +- .../iothub/v2017_01_19/aio/_configuration.py | 51 +- .../iothub/v2017_01_19/aio/_iot_hub_client.py | 25 +- .../mgmt/iothub/v2017_01_19/aio/_patch.py | 2 +- .../v2017_01_19/aio/operations/__init__.py | 8 +- .../_iot_hub_resource_operations.py | 1555 +++--- .../v2017_01_19/aio/operations/_patch.py | 20 + .../iothub/v2017_01_19/models/__init__.py | 124 +- .../models/_iot_hub_client_enums.py | 72 +- .../iothub/v2017_01_19/models/_models_py3.py | 1088 ++--- .../mgmt/iothub/v2017_01_19/models/_patch.py | 20 + .../iothub/v2017_01_19/operations/__init__.py | 8 +- .../_iot_hub_resource_operations.py | 2375 +++++---- .../iothub/v2017_01_19/operations/_patch.py | 20 + .../azure/mgmt/iothub/v2017_07_01/__init__.py | 16 +- .../mgmt/iothub/v2017_07_01/_configuration.py | 49 +- .../iothub/v2017_07_01/_iot_hub_client.py | 25 +- .../mgmt/iothub/v2017_07_01/_metadata.json | 18 +- .../azure/mgmt/iothub/v2017_07_01/_patch.py | 2 +- .../azure/mgmt/iothub/v2017_07_01/_vendor.py | 6 +- .../azure/mgmt/iothub/v2017_07_01/_version.py | 2 +- .../mgmt/iothub/v2017_07_01/aio/__init__.py | 16 +- .../iothub/v2017_07_01/aio/_configuration.py | 51 +- .../iothub/v2017_07_01/aio/_iot_hub_client.py | 25 +- .../mgmt/iothub/v2017_07_01/aio/_patch.py | 2 +- .../v2017_07_01/aio/operations/__init__.py | 12 +- .../operations/_certificates_operations.py | 539 ++- .../_iot_hub_resource_operations.py | 1568 +++--- .../v2017_07_01/aio/operations/_operations.py | 102 +- .../v2017_07_01/aio/operations/_patch.py | 20 + .../iothub/v2017_07_01/models/__init__.py | 146 +- .../models/_iot_hub_client_enums.py | 72 +- .../iothub/v2017_07_01/models/_models_py3.py | 1398 +++--- .../mgmt/iothub/v2017_07_01/models/_patch.py | 20 + .../iothub/v2017_07_01/operations/__init__.py | 12 +- .../operations/_certificates_operations.py | 813 ++-- .../_iot_hub_resource_operations.py | 2391 +++++----- .../v2017_07_01/operations/_operations.py | 142 +- .../iothub/v2017_07_01/operations/_patch.py | 20 + .../azure/mgmt/iothub/v2018_01_22/__init__.py | 16 +- .../mgmt/iothub/v2018_01_22/_configuration.py | 49 +- .../iothub/v2018_01_22/_iot_hub_client.py | 25 +- .../mgmt/iothub/v2018_01_22/_metadata.json | 18 +- .../azure/mgmt/iothub/v2018_01_22/_patch.py | 2 +- .../azure/mgmt/iothub/v2018_01_22/_vendor.py | 6 +- .../azure/mgmt/iothub/v2018_01_22/_version.py | 2 +- .../mgmt/iothub/v2018_01_22/aio/__init__.py | 16 +- .../iothub/v2018_01_22/aio/_configuration.py | 51 +- .../iothub/v2018_01_22/aio/_iot_hub_client.py | 25 +- .../mgmt/iothub/v2018_01_22/aio/_patch.py | 2 +- .../v2018_01_22/aio/operations/__init__.py | 12 +- .../operations/_certificates_operations.py | 539 ++- .../_iot_hub_resource_operations.py | 1759 ++++--- .../v2018_01_22/aio/operations/_operations.py | 102 +- .../v2018_01_22/aio/operations/_patch.py | 20 + .../iothub/v2018_01_22/models/__init__.py | 148 +- .../models/_iot_hub_client_enums.py | 72 +- .../iothub/v2018_01_22/models/_models_py3.py | 1404 +++--- .../mgmt/iothub/v2018_01_22/models/_patch.py | 20 + .../iothub/v2018_01_22/operations/__init__.py | 12 +- .../operations/_certificates_operations.py | 813 ++-- .../_iot_hub_resource_operations.py | 2635 +++++----- .../v2018_01_22/operations/_operations.py | 142 +- .../iothub/v2018_01_22/operations/_patch.py | 20 + .../azure/mgmt/iothub/v2018_04_01/__init__.py | 16 +- .../mgmt/iothub/v2018_04_01/_configuration.py | 49 +- .../iothub/v2018_04_01/_iot_hub_client.py | 29 +- .../mgmt/iothub/v2018_04_01/_metadata.json | 18 +- .../azure/mgmt/iothub/v2018_04_01/_patch.py | 2 +- .../azure/mgmt/iothub/v2018_04_01/_vendor.py | 6 +- .../azure/mgmt/iothub/v2018_04_01/_version.py | 2 +- .../mgmt/iothub/v2018_04_01/aio/__init__.py | 16 +- .../iothub/v2018_04_01/aio/_configuration.py | 51 +- .../iothub/v2018_04_01/aio/_iot_hub_client.py | 29 +- .../mgmt/iothub/v2018_04_01/aio/_patch.py | 2 +- .../v2018_04_01/aio/operations/__init__.py | 14 +- .../operations/_certificates_operations.py | 539 ++- .../_iot_hub_resource_operations.py | 2059 +++++--- .../v2018_04_01/aio/operations/_operations.py | 102 +- .../v2018_04_01/aio/operations/_patch.py | 20 + .../_resource_provider_common_operations.py | 87 +- .../iothub/v2018_04_01/models/__init__.py | 194 +- .../models/_iot_hub_client_enums.py | 90 +- .../iothub/v2018_04_01/models/_models_py3.py | 1721 +++---- .../mgmt/iothub/v2018_04_01/models/_patch.py | 20 + .../iothub/v2018_04_01/operations/__init__.py | 14 +- .../operations/_certificates_operations.py | 813 ++-- .../_iot_hub_resource_operations.py | 3103 +++++++----- .../v2018_04_01/operations/_operations.py | 142 +- .../iothub/v2018_04_01/operations/_patch.py | 20 + .../_resource_provider_common_operations.py | 131 +- .../azure/mgmt/iothub/v2019_03_22/__init__.py | 16 +- .../mgmt/iothub/v2019_03_22/_configuration.py | 49 +- .../iothub/v2019_03_22/_iot_hub_client.py | 37 +- .../mgmt/iothub/v2019_03_22/_metadata.json | 18 +- .../azure/mgmt/iothub/v2019_03_22/_patch.py | 2 +- .../azure/mgmt/iothub/v2019_03_22/_vendor.py | 6 +- .../azure/mgmt/iothub/v2019_03_22/_version.py | 2 +- .../mgmt/iothub/v2019_03_22/aio/__init__.py | 16 +- .../iothub/v2019_03_22/aio/_configuration.py | 51 +- .../iothub/v2019_03_22/aio/_iot_hub_client.py | 37 +- .../mgmt/iothub/v2019_03_22/aio/_patch.py | 2 +- .../v2019_03_22/aio/operations/__init__.py | 16 +- .../operations/_certificates_operations.py | 539 ++- .../aio/operations/_iot_hub_operations.py | 233 +- .../_iot_hub_resource_operations.py | 2059 +++++--- .../v2019_03_22/aio/operations/_operations.py | 102 +- .../v2019_03_22/aio/operations/_patch.py | 20 + .../_resource_provider_common_operations.py | 87 +- .../iothub/v2019_03_22/models/__init__.py | 200 +- .../models/_iot_hub_client_enums.py | 89 +- .../iothub/v2019_03_22/models/_models_py3.py | 1754 +++---- .../mgmt/iothub/v2019_03_22/models/_patch.py | 20 + .../iothub/v2019_03_22/operations/__init__.py | 16 +- .../operations/_certificates_operations.py | 813 ++-- .../operations/_iot_hub_operations.py | 293 +- .../_iot_hub_resource_operations.py | 3103 +++++++----- .../v2019_03_22/operations/_operations.py | 142 +- .../iothub/v2019_03_22/operations/_patch.py | 20 + .../_resource_provider_common_operations.py | 131 +- .../iothub/v2019_07_01_preview/__init__.py | 16 +- .../v2019_07_01_preview/_configuration.py | 49 +- .../v2019_07_01_preview/_iot_hub_client.py | 37 +- .../iothub/v2019_07_01_preview/_metadata.json | 18 +- .../mgmt/iothub/v2019_07_01_preview/_patch.py | 2 +- .../iothub/v2019_07_01_preview/_vendor.py | 6 +- .../iothub/v2019_07_01_preview/_version.py | 2 +- .../v2019_07_01_preview/aio/__init__.py | 16 +- .../v2019_07_01_preview/aio/_configuration.py | 51 +- .../aio/_iot_hub_client.py | 37 +- .../iothub/v2019_07_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 16 +- .../operations/_certificates_operations.py | 541 ++- .../aio/operations/_iot_hub_operations.py | 227 +- .../_iot_hub_resource_operations.py | 2061 +++++--- .../aio/operations/_operations.py | 102 +- .../aio/operations/_patch.py | 20 + .../_resource_provider_common_operations.py | 87 +- .../v2019_07_01_preview/models/__init__.py | 204 +- .../models/_iot_hub_client_enums.py | 92 +- .../v2019_07_01_preview/models/_models_py3.py | 1819 ++++--- .../v2019_07_01_preview/models/_patch.py | 20 + .../operations/__init__.py | 16 +- .../operations/_certificates_operations.py | 815 ++-- .../operations/_iot_hub_operations.py | 287 +- .../_iot_hub_resource_operations.py | 3105 +++++++----- .../operations/_operations.py | 143 +- .../v2019_07_01_preview/operations/_patch.py | 20 + .../_resource_provider_common_operations.py | 131 +- .../azure/mgmt/iothub/v2019_11_04/__init__.py | 16 +- .../mgmt/iothub/v2019_11_04/_configuration.py | 49 +- .../iothub/v2019_11_04/_iot_hub_client.py | 37 +- .../mgmt/iothub/v2019_11_04/_metadata.json | 18 +- .../azure/mgmt/iothub/v2019_11_04/_patch.py | 2 +- .../azure/mgmt/iothub/v2019_11_04/_vendor.py | 6 +- .../azure/mgmt/iothub/v2019_11_04/_version.py | 2 +- .../mgmt/iothub/v2019_11_04/aio/__init__.py | 16 +- .../iothub/v2019_11_04/aio/_configuration.py | 51 +- .../iothub/v2019_11_04/aio/_iot_hub_client.py | 37 +- .../mgmt/iothub/v2019_11_04/aio/_patch.py | 2 +- .../v2019_11_04/aio/operations/__init__.py | 16 +- .../operations/_certificates_operations.py | 539 ++- .../aio/operations/_iot_hub_operations.py | 233 +- .../_iot_hub_resource_operations.py | 2059 +++++--- .../v2019_11_04/aio/operations/_operations.py | 102 +- .../v2019_11_04/aio/operations/_patch.py | 20 + .../_resource_provider_common_operations.py | 87 +- .../iothub/v2019_11_04/models/__init__.py | 202 +- .../models/_iot_hub_client_enums.py | 89 +- .../iothub/v2019_11_04/models/_models_py3.py | 1799 +++---- .../mgmt/iothub/v2019_11_04/models/_patch.py | 20 + .../iothub/v2019_11_04/operations/__init__.py | 16 +- .../operations/_certificates_operations.py | 813 ++-- .../operations/_iot_hub_operations.py | 293 +- .../_iot_hub_resource_operations.py | 3103 +++++++----- .../v2019_11_04/operations/_operations.py | 142 +- .../iothub/v2019_11_04/operations/_patch.py | 20 + .../_resource_provider_common_operations.py | 131 +- .../azure/mgmt/iothub/v2020_03_01/__init__.py | 16 +- .../mgmt/iothub/v2020_03_01/_configuration.py | 49 +- .../iothub/v2020_03_01/_iot_hub_client.py | 49 +- .../mgmt/iothub/v2020_03_01/_metadata.json | 18 +- .../azure/mgmt/iothub/v2020_03_01/_patch.py | 2 +- .../azure/mgmt/iothub/v2020_03_01/_vendor.py | 6 +- .../azure/mgmt/iothub/v2020_03_01/_version.py | 2 +- .../mgmt/iothub/v2020_03_01/aio/__init__.py | 16 +- .../iothub/v2020_03_01/aio/_configuration.py | 51 +- .../iothub/v2020_03_01/aio/_iot_hub_client.py | 49 +- .../mgmt/iothub/v2020_03_01/aio/_patch.py | 2 +- .../v2020_03_01/aio/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 539 ++- .../aio/operations/_iot_hub_operations.py | 233 +- .../_iot_hub_resource_operations.py | 2059 +++++--- .../v2020_03_01/aio/operations/_operations.py | 102 +- .../v2020_03_01/aio/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 469 +- .../_private_link_resources_operations.py | 146 +- .../_resource_provider_common_operations.py | 87 +- .../iothub/v2020_03_01/models/__init__.py | 228 +- .../models/_iot_hub_client_enums.py | 107 +- .../iothub/v2020_03_01/models/_models_py3.py | 2041 ++++---- .../mgmt/iothub/v2020_03_01/models/_patch.py | 20 + .../iothub/v2020_03_01/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 813 ++-- .../operations/_iot_hub_operations.py | 293 +- .../_iot_hub_resource_operations.py | 3103 +++++++----- .../v2020_03_01/operations/_operations.py | 142 +- .../iothub/v2020_03_01/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 649 +-- .../_private_link_resources_operations.py | 240 +- .../_resource_provider_common_operations.py | 131 +- .../iothub/v2021_03_03_preview/__init__.py | 16 +- .../v2021_03_03_preview/_configuration.py | 49 +- .../v2021_03_03_preview/_iot_hub_client.py | 49 +- .../iothub/v2021_03_03_preview/_metadata.json | 18 +- .../mgmt/iothub/v2021_03_03_preview/_patch.py | 2 +- .../iothub/v2021_03_03_preview/_vendor.py | 6 +- .../iothub/v2021_03_03_preview/_version.py | 2 +- .../v2021_03_03_preview/aio/__init__.py | 16 +- .../v2021_03_03_preview/aio/_configuration.py | 51 +- .../aio/_iot_hub_client.py | 49 +- .../iothub/v2021_03_03_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 541 ++- .../aio/operations/_iot_hub_operations.py | 233 +- .../_iot_hub_resource_operations.py | 2140 ++++++--- .../aio/operations/_operations.py | 102 +- .../aio/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 469 +- .../_private_link_resources_operations.py | 146 +- .../_resource_provider_common_operations.py | 87 +- .../v2021_03_03_preview/models/__init__.py | 260 +- .../models/_iot_hub_client_enums.py | 122 +- .../v2021_03_03_preview/models/_models_py3.py | 2306 ++++----- .../v2021_03_03_preview/models/_patch.py | 20 + .../operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 815 ++-- .../operations/_iot_hub_operations.py | 293 +- .../_iot_hub_resource_operations.py | 3248 +++++++------ .../operations/_operations.py | 143 +- .../v2021_03_03_preview/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 649 +-- .../_private_link_resources_operations.py | 240 +- .../_resource_provider_common_operations.py | 131 +- .../azure/mgmt/iothub/v2021_03_31/__init__.py | 16 +- .../mgmt/iothub/v2021_03_31/_configuration.py | 49 +- .../iothub/v2021_03_31/_iot_hub_client.py | 49 +- .../mgmt/iothub/v2021_03_31/_metadata.json | 18 +- .../azure/mgmt/iothub/v2021_03_31/_patch.py | 2 +- .../azure/mgmt/iothub/v2021_03_31/_vendor.py | 6 +- .../azure/mgmt/iothub/v2021_03_31/_version.py | 2 +- .../mgmt/iothub/v2021_03_31/aio/__init__.py | 16 +- .../iothub/v2021_03_31/aio/_configuration.py | 51 +- .../iothub/v2021_03_31/aio/_iot_hub_client.py | 49 +- .../mgmt/iothub/v2021_03_31/aio/_patch.py | 2 +- .../v2021_03_31/aio/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 541 ++- .../aio/operations/_iot_hub_operations.py | 233 +- .../_iot_hub_resource_operations.py | 2142 ++++++--- .../v2021_03_31/aio/operations/_operations.py | 102 +- .../v2021_03_31/aio/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 469 +- .../_private_link_resources_operations.py | 146 +- .../_resource_provider_common_operations.py | 87 +- .../iothub/v2021_03_31/models/__init__.py | 254 +- .../models/_iot_hub_client_enums.py | 122 +- .../iothub/v2021_03_31/models/_models_py3.py | 2270 ++++----- .../mgmt/iothub/v2021_03_31/models/_patch.py | 20 + .../iothub/v2021_03_31/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 815 ++-- .../operations/_iot_hub_operations.py | 293 +- .../_iot_hub_resource_operations.py | 3246 +++++++------ .../v2021_03_31/operations/_operations.py | 142 +- .../iothub/v2021_03_31/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 649 +-- .../_private_link_resources_operations.py | 240 +- .../_resource_provider_common_operations.py | 131 +- .../azure/mgmt/iothub/v2021_07_01/__init__.py | 16 +- .../mgmt/iothub/v2021_07_01/_configuration.py | 49 +- .../iothub/v2021_07_01/_iot_hub_client.py | 49 +- .../mgmt/iothub/v2021_07_01/_metadata.json | 18 +- .../azure/mgmt/iothub/v2021_07_01/_patch.py | 2 +- .../azure/mgmt/iothub/v2021_07_01/_vendor.py | 6 +- .../azure/mgmt/iothub/v2021_07_01/_version.py | 2 +- .../mgmt/iothub/v2021_07_01/aio/__init__.py | 16 +- .../iothub/v2021_07_01/aio/_configuration.py | 51 +- .../iothub/v2021_07_01/aio/_iot_hub_client.py | 49 +- .../mgmt/iothub/v2021_07_01/aio/_patch.py | 2 +- .../v2021_07_01/aio/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 541 ++- .../aio/operations/_iot_hub_operations.py | 233 +- .../_iot_hub_resource_operations.py | 2142 ++++++--- .../v2021_07_01/aio/operations/_operations.py | 102 +- .../v2021_07_01/aio/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 469 +- .../_private_link_resources_operations.py | 146 +- .../_resource_provider_common_operations.py | 87 +- .../iothub/v2021_07_01/models/__init__.py | 254 +- .../models/_iot_hub_client_enums.py | 122 +- .../iothub/v2021_07_01/models/_models_py3.py | 2292 ++++----- .../mgmt/iothub/v2021_07_01/models/_patch.py | 20 + .../iothub/v2021_07_01/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 815 ++-- .../operations/_iot_hub_operations.py | 293 +- .../_iot_hub_resource_operations.py | 3246 +++++++------ .../v2021_07_01/operations/_operations.py | 142 +- .../iothub/v2021_07_01/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 649 +-- .../_private_link_resources_operations.py | 240 +- .../_resource_provider_common_operations.py | 131 +- .../azure/mgmt/iothub/v2021_07_02/__init__.py | 16 +- .../mgmt/iothub/v2021_07_02/_configuration.py | 49 +- .../iothub/v2021_07_02/_iot_hub_client.py | 49 +- .../mgmt/iothub/v2021_07_02/_metadata.json | 18 +- .../azure/mgmt/iothub/v2021_07_02/_patch.py | 2 +- .../azure/mgmt/iothub/v2021_07_02/_vendor.py | 6 +- .../azure/mgmt/iothub/v2021_07_02/_version.py | 2 +- .../mgmt/iothub/v2021_07_02/aio/__init__.py | 16 +- .../iothub/v2021_07_02/aio/_configuration.py | 51 +- .../iothub/v2021_07_02/aio/_iot_hub_client.py | 49 +- .../mgmt/iothub/v2021_07_02/aio/_patch.py | 2 +- .../v2021_07_02/aio/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 541 ++- .../aio/operations/_iot_hub_operations.py | 233 +- .../_iot_hub_resource_operations.py | 2142 ++++++--- .../v2021_07_02/aio/operations/_operations.py | 102 +- .../v2021_07_02/aio/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 469 +- .../_private_link_resources_operations.py | 146 +- .../_resource_provider_common_operations.py | 87 +- .../iothub/v2021_07_02/models/__init__.py | 260 +- .../models/_iot_hub_client_enums.py | 128 +- .../iothub/v2021_07_02/models/_models_py3.py | 2334 ++++----- .../mgmt/iothub/v2021_07_02/models/_patch.py | 20 + .../iothub/v2021_07_02/operations/__init__.py | 20 +- .../operations/_certificates_operations.py | 815 ++-- .../operations/_iot_hub_operations.py | 293 +- .../_iot_hub_resource_operations.py | 3246 +++++++------ .../v2021_07_02/operations/_operations.py | 142 +- .../iothub/v2021_07_02/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 649 +-- .../_private_link_resources_operations.py | 240 +- .../_resource_provider_common_operations.py | 131 +- .../iothub/v2022_04_30_preview/__init__.py | 24 + .../v2022_04_30_preview/_configuration.py | 69 + .../v2022_04_30_preview/_iot_hub_client.py | 128 + .../iothub/v2022_04_30_preview/_metadata.json | 108 + .../mgmt/iothub/v2022_04_30_preview/_patch.py | 20 + .../iothub/v2022_04_30_preview/_vendor.py | 27 + .../iothub/v2022_04_30_preview/_version.py | 9 + .../v2022_04_30_preview/aio/__init__.py | 21 + .../v2022_04_30_preview/aio/_configuration.py | 66 + .../aio/_iot_hub_client.py | 126 + .../iothub/v2022_04_30_preview/aio/_patch.py | 20 + .../aio/operations/__init__.py | 31 + .../operations/_certificates_operations.py | 631 +++ .../aio/operations/_iot_hub_operations.py | 269 ++ .../_iot_hub_resource_operations.py | 2523 ++++++++++ .../aio/operations/_operations.py | 120 + .../aio/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 546 +++ .../_private_link_resources_operations.py | 167 + .../_resource_provider_common_operations.py | 100 + .../v2022_04_30_preview/models/__init__.py | 235 + .../models/_iot_hub_client_enums.py | 231 + .../v2022_04_30_preview/models/_models_py3.py | 4236 +++++++++++++++++ .../v2022_04_30_preview/models/_patch.py | 20 + .../operations/__init__.py | 31 + .../operations/_certificates_operations.py | 863 ++++ .../operations/_iot_hub_operations.py | 306 ++ .../_iot_hub_resource_operations.py | 3237 +++++++++++++ .../operations/_operations.py | 141 + .../v2022_04_30_preview/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 692 +++ .../_private_link_resources_operations.py | 233 + .../_resource_provider_common_operations.py | 127 + .../mgmt/iothub/v2022_04_30_preview/py.typed | 1 + 411 files changed, 90424 insertions(+), 53065 deletions(-) create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/__init__.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_configuration.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_iot_hub_client.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_metadata.json create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_vendor.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_version.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/__init__.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_configuration.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_iot_hub_client.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/__init__.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_certificates_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_resource_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_link_resources_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_resource_provider_common_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/__init__.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_iot_hub_client_enums.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_models_py3.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/__init__.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_certificates_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_resource_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_link_resources_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_resource_provider_common_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/py.typed diff --git a/sdk/iothub/azure-mgmt-iothub/_meta.json b/sdk/iothub/azure-mgmt-iothub/_meta.json index 7e8005ab6368..19a436f66524 100644 --- a/sdk/iothub/azure-mgmt-iothub/_meta.json +++ b/sdk/iothub/azure-mgmt-iothub/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.12.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.0.1", + "@autorest/modelerfour@4.23.5" ], - "commit": "f9a6cb686bcc0f1b23761db19f2491c5c4df95cb", + "commit": "2e2b50a9ca9c5b775f2cb76f92b950b351f7c1e2", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/iothub/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/iothub/resource-manager/readme.md --models-mode=msrest --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.0.1 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/iothub/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py index b1d4bbf2aaf3..c38551cfabf9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class IotHubClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class IotHubClientConfiguration(Configuration): 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_iot_hub_client.py index fdacdc579193..f480991eb801 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_iot_hub_client.py @@ -9,19 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import IotHubClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class IotHubClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -66,10 +64,10 @@ class IotHubClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): @@ -101,6 +99,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-03-31: :mod:`v2021_03_31.models` * 2021-07-01: :mod:`v2021_07_01.models` * 2021-07-02: :mod:`v2021_07_02.models` + * 2022-04-30-preview: :mod:`v2022_04_30_preview.models` """ if api_version == '2016-02-03': from .v2016_02_03 import models @@ -141,6 +140,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-07-02': from .v2021_07_02 import models return models + elif api_version == '2022-04-30-preview': + from .v2022_04_30_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -158,6 +160,7 @@ def certificates(self): * 2021-03-31: :class:`CertificatesOperations` * 2021-07-01: :class:`CertificatesOperations` * 2021-07-02: :class:`CertificatesOperations` + * 2022-04-30-preview: :class:`CertificatesOperations` """ api_version = self._get_api_version('certificates') if api_version == '2017-07-01': @@ -182,6 +185,8 @@ def certificates(self): from .v2021_07_01.operations import CertificatesOperations as OperationClass elif api_version == '2021-07-02': from .v2021_07_02.operations import CertificatesOperations as OperationClass + elif api_version == '2022-04-30-preview': + from .v2022_04_30_preview.operations import CertificatesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'certificates'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -198,6 +203,7 @@ def iot_hub(self): * 2021-03-31: :class:`IotHubOperations` * 2021-07-01: :class:`IotHubOperations` * 2021-07-02: :class:`IotHubOperations` + * 2022-04-30-preview: :class:`IotHubOperations` """ api_version = self._get_api_version('iot_hub') if api_version == '2019-03-22': @@ -216,6 +222,8 @@ def iot_hub(self): from .v2021_07_01.operations import IotHubOperations as OperationClass elif api_version == '2021-07-02': from .v2021_07_02.operations import IotHubOperations as OperationClass + elif api_version == '2022-04-30-preview': + from .v2022_04_30_preview.operations import IotHubOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_hub'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -237,6 +245,7 @@ def iot_hub_resource(self): * 2021-03-31: :class:`IotHubResourceOperations` * 2021-07-01: :class:`IotHubResourceOperations` * 2021-07-02: :class:`IotHubResourceOperations` + * 2022-04-30-preview: :class:`IotHubResourceOperations` """ api_version = self._get_api_version('iot_hub_resource') if api_version == '2016-02-03': @@ -265,6 +274,8 @@ def iot_hub_resource(self): from .v2021_07_01.operations import IotHubResourceOperations as OperationClass elif api_version == '2021-07-02': from .v2021_07_02.operations import IotHubResourceOperations as OperationClass + elif api_version == '2022-04-30-preview': + from .v2022_04_30_preview.operations import IotHubResourceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_hub_resource'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -284,6 +295,7 @@ def operations(self): * 2021-03-31: :class:`Operations` * 2021-07-01: :class:`Operations` * 2021-07-02: :class:`Operations` + * 2022-04-30-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-07-01': @@ -308,6 +320,8 @@ def operations(self): from .v2021_07_01.operations import Operations as OperationClass elif api_version == '2021-07-02': from .v2021_07_02.operations import Operations as OperationClass + elif api_version == '2022-04-30-preview': + from .v2022_04_30_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -321,6 +335,7 @@ def private_endpoint_connections(self): * 2021-03-31: :class:`PrivateEndpointConnectionsOperations` * 2021-07-01: :class:`PrivateEndpointConnectionsOperations` * 2021-07-02: :class:`PrivateEndpointConnectionsOperations` + * 2022-04-30-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2020-03-01': @@ -333,6 +348,8 @@ def private_endpoint_connections(self): from .v2021_07_01.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2021-07-02': from .v2021_07_02.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-04-30-preview': + from .v2022_04_30_preview.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -346,6 +363,7 @@ def private_link_resources(self): * 2021-03-31: :class:`PrivateLinkResourcesOperations` * 2021-07-01: :class:`PrivateLinkResourcesOperations` * 2021-07-02: :class:`PrivateLinkResourcesOperations` + * 2022-04-30-preview: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2020-03-01': @@ -358,6 +376,8 @@ def private_link_resources(self): from .v2021_07_01.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2021-07-02': from .v2021_07_02.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2022-04-30-preview': + from .v2022_04_30_preview.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -375,6 +395,7 @@ def resource_provider_common(self): * 2021-03-31: :class:`ResourceProviderCommonOperations` * 2021-07-01: :class:`ResourceProviderCommonOperations` * 2021-07-02: :class:`ResourceProviderCommonOperations` + * 2022-04-30-preview: :class:`ResourceProviderCommonOperations` """ api_version = self._get_api_version('resource_provider_common') if api_version == '2018-04-01': @@ -395,6 +416,8 @@ def resource_provider_common(self): from .v2021_07_01.operations import ResourceProviderCommonOperations as OperationClass elif api_version == '2021-07-02': from .v2021_07_02.operations import ResourceProviderCommonOperations as OperationClass + elif api_version == '2022-04-30-preview': + from .v2022_04_30_preview.operations import ResourceProviderCommonOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'resource_provider_common'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py new file mode 100644 index 000000000000..2e44d8666b2b --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# 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. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if 'name' not in getattr(orig_attr, '_xml_map', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node( + xml_name, + xml_prefix, + xml_ns + ) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [ + self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" + for d + in data + ] + if not kwargs.get('skip_quote', False): + data = [ + quote(str(d), safe='') + for d + in data + ] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get('name', internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get('ns', internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [ + rest_key_extractor, + xml_key_extractor + ] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc['type']) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text, + raw_data.headers + ) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, 'read'): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_configuration.py index 51c9f055ca69..22e8405004a6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_configuration.py @@ -26,9 +26,9 @@ class IotHubClientConfiguration(Configuration): 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_iot_hub_client.py index 177125990133..865f05b4ea5b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_iot_hub_client.py @@ -14,13 +14,12 @@ from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -41,9 +40,9 @@ class IotHubClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -100,6 +99,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-03-31: :mod:`v2021_03_31.models` * 2021-07-01: :mod:`v2021_07_01.models` * 2021-07-02: :mod:`v2021_07_02.models` + * 2022-04-30-preview: :mod:`v2022_04_30_preview.models` """ if api_version == '2016-02-03': from ..v2016_02_03 import models @@ -140,6 +140,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-07-02': from ..v2021_07_02 import models return models + elif api_version == '2022-04-30-preview': + from ..v2022_04_30_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -157,6 +160,7 @@ def certificates(self): * 2021-03-31: :class:`CertificatesOperations` * 2021-07-01: :class:`CertificatesOperations` * 2021-07-02: :class:`CertificatesOperations` + * 2022-04-30-preview: :class:`CertificatesOperations` """ api_version = self._get_api_version('certificates') if api_version == '2017-07-01': @@ -181,6 +185,8 @@ def certificates(self): from ..v2021_07_01.aio.operations import CertificatesOperations as OperationClass elif api_version == '2021-07-02': from ..v2021_07_02.aio.operations import CertificatesOperations as OperationClass + elif api_version == '2022-04-30-preview': + from ..v2022_04_30_preview.aio.operations import CertificatesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'certificates'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -197,6 +203,7 @@ def iot_hub(self): * 2021-03-31: :class:`IotHubOperations` * 2021-07-01: :class:`IotHubOperations` * 2021-07-02: :class:`IotHubOperations` + * 2022-04-30-preview: :class:`IotHubOperations` """ api_version = self._get_api_version('iot_hub') if api_version == '2019-03-22': @@ -215,6 +222,8 @@ def iot_hub(self): from ..v2021_07_01.aio.operations import IotHubOperations as OperationClass elif api_version == '2021-07-02': from ..v2021_07_02.aio.operations import IotHubOperations as OperationClass + elif api_version == '2022-04-30-preview': + from ..v2022_04_30_preview.aio.operations import IotHubOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_hub'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -236,6 +245,7 @@ def iot_hub_resource(self): * 2021-03-31: :class:`IotHubResourceOperations` * 2021-07-01: :class:`IotHubResourceOperations` * 2021-07-02: :class:`IotHubResourceOperations` + * 2022-04-30-preview: :class:`IotHubResourceOperations` """ api_version = self._get_api_version('iot_hub_resource') if api_version == '2016-02-03': @@ -264,6 +274,8 @@ def iot_hub_resource(self): from ..v2021_07_01.aio.operations import IotHubResourceOperations as OperationClass elif api_version == '2021-07-02': from ..v2021_07_02.aio.operations import IotHubResourceOperations as OperationClass + elif api_version == '2022-04-30-preview': + from ..v2022_04_30_preview.aio.operations import IotHubResourceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_hub_resource'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -283,6 +295,7 @@ def operations(self): * 2021-03-31: :class:`Operations` * 2021-07-01: :class:`Operations` * 2021-07-02: :class:`Operations` + * 2022-04-30-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-07-01': @@ -307,6 +320,8 @@ def operations(self): from ..v2021_07_01.aio.operations import Operations as OperationClass elif api_version == '2021-07-02': from ..v2021_07_02.aio.operations import Operations as OperationClass + elif api_version == '2022-04-30-preview': + from ..v2022_04_30_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -320,6 +335,7 @@ def private_endpoint_connections(self): * 2021-03-31: :class:`PrivateEndpointConnectionsOperations` * 2021-07-01: :class:`PrivateEndpointConnectionsOperations` * 2021-07-02: :class:`PrivateEndpointConnectionsOperations` + * 2022-04-30-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2020-03-01': @@ -332,6 +348,8 @@ def private_endpoint_connections(self): from ..v2021_07_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2021-07-02': from ..v2021_07_02.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-04-30-preview': + from ..v2022_04_30_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -345,6 +363,7 @@ def private_link_resources(self): * 2021-03-31: :class:`PrivateLinkResourcesOperations` * 2021-07-01: :class:`PrivateLinkResourcesOperations` * 2021-07-02: :class:`PrivateLinkResourcesOperations` + * 2022-04-30-preview: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2020-03-01': @@ -357,6 +376,8 @@ def private_link_resources(self): from ..v2021_07_01.aio.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2021-07-02': from ..v2021_07_02.aio.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2022-04-30-preview': + from ..v2022_04_30_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -374,6 +395,7 @@ def resource_provider_common(self): * 2021-03-31: :class:`ResourceProviderCommonOperations` * 2021-07-01: :class:`ResourceProviderCommonOperations` * 2021-07-02: :class:`ResourceProviderCommonOperations` + * 2022-04-30-preview: :class:`ResourceProviderCommonOperations` """ api_version = self._get_api_version('resource_provider_common') if api_version == '2018-04-01': @@ -394,6 +416,8 @@ def resource_provider_common(self): from ..v2021_07_01.aio.operations import ResourceProviderCommonOperations as OperationClass elif api_version == '2021-07-02': from ..v2021_07_02.aio.operations import ResourceProviderCommonOperations as OperationClass + elif api_version == '2022-04-30-preview': + from ..v2022_04_30_preview.aio.operations import ResourceProviderCommonOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'resource_provider_common'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py index 6e6027d8fc1d..fe393233cee1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-02-03". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2016-02-03") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-02-03" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py index 9119653bc5df..02b1f576fdc6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import IotHubResourceOperations @@ -21,17 +21,21 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2016_02_03.operations.IotHubResourceOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-02-03". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -52,12 +56,7 @@ def __init__( self._serialize.client_side_validation = False self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -66,7 +65,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_metadata.json index fea5ebde91cf..95060ef31fdc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py index b421ff804730..c5e320081f03 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-02-03". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2016-02-03") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-02-03" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py index 6724987d2c6c..521305468807 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import IotHubResourceOperations @@ -21,18 +21,22 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2016_02_03.aio.operations.IotHubResourceOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-02-03". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -53,12 +57,7 @@ def __init__( self._serialize.client_side_validation = False self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -67,7 +66,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/__init__.py index e4c608fe7497..972b73cd63bb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/__init__.py @@ -8,6 +8,12 @@ from ._iot_hub_resource_operations import IotHubResourceOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'IotHubResourceOperations', + "IotHubResourceOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py index 25aa4329f8d7..b71570d38241 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,114 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2016_02_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2016_02_03.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,73 +121,171 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub to create or update. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub to create or update. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -167,12 +294,16 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub to create or update. + :param resource_name: The name of the IoT hub to create or update. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -185,111 +316,117 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub to delete. + :param resource_name: The name of the IoT hub to delete. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -299,91 +436,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription or - ~azure.mgmt.iothub.v2016_02_03.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -397,7 +541,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,56 +553,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. :param resource_group_name: The name of the resource group that contains the IoT hubs. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -470,7 +618,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -480,49 +630,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -530,65 +683,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -602,7 +756,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -612,68 +768,64 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable[str]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[str] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -687,7 +839,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -697,57 +851,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -755,61 +911,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -817,61 +976,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -882,60 +1044,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -949,7 +1111,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -959,55 +1123,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1015,65 +1181,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1087,7 +1254,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1097,50 +1266,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2016_02_03.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2016_02_03.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] - _json = self._serialize.body(operation_inputs, 'OperationInputs') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1148,67 +1371,68 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1222,7 +1446,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,55 +1458,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1288,24 +1516,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1314,39 +1543,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2016_02_03.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2016_02_03.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1354,24 +1669,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1380,39 +1696,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2016_02_03.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2016_02_03.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1420,12 +1822,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/__init__.py index a89eff43c517..97481abddb80 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/__init__.py @@ -36,58 +36,60 @@ from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult from ._models_py3 import StorageEndpointProperties - -from ._iot_hub_client_enums import ( - AccessRights, - Capabilities, - IotHubNameUnavailabilityReason, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - OperationMonitoringLevel, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import OperationMonitoringLevel +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CloudToDeviceProperties', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FeedbackProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MessagingEndpointProperties', - 'OperationInputs', - 'OperationsMonitoringProperties', - 'RegistryStatistics', - 'Resource', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'AccessRights', - 'Capabilities', - 'IotHubNameUnavailabilityReason', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'OperationMonitoringLevel', + "CloudToDeviceProperties", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FeedbackProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MessagingEndpointProperties", + "OperationInputs", + "OperationsMonitoringProperties", + "RegistryStatistics", + "Resource", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "AccessRights", + "Capabilities", + "IotHubNameUnavailabilityReason", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "OperationMonitoringLevel", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py index 80da5a05a045..d36ac303bb1f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,56 +27,58 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" S2 = "S2" S3 = "S3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -87,13 +87,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -102,9 +102,9 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operations monitoring level. - """ + +class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operations monitoring level.""" NONE = "None" ERROR = "Error" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py index 08560b2ead5b..92329bf19f10 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -31,13 +33,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -45,7 +47,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -60,13 +62,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2016_02_03.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -82,36 +84,32 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'Code', 'type': 'str'}, - 'http_status_code': {'key': 'HttpStatusCode', 'type': 'str'}, - 'message': {'key': 'Message', 'type': 'str'}, - 'details': {'key': 'Details', 'type': 'str'}, + "code": {"key": "Code", "type": "str"}, + "http_status_code": {"key": "HttpStatusCode", "type": "str"}, + "message": {"key": "Message", "type": "str"}, + "details": {"key": "Details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. - :ivar tags: A set of tags. The tags. + :ivar tags: The tags. :vartype tags: dict[str, str] :ivar id: The Event Hub-compatible consumer group identifier. :vartype id: str @@ -120,34 +118,34 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags. + :keyword tags: The tags. :paramtype tags: dict[str, str] :keyword id: The Event Hub-compatible consumer group identifier. :paramtype id: str :keyword name: The Event Hub-compatible consumer group name. :paramtype name: str """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.id = id self.name = name -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -159,37 +157,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[str]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List[str]] = None, **kwargs): """ :keyword value: The array of Event Hub-compatible consumer group names. :paramtype value: list[str] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -203,36 +196,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -240,48 +229,42 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'ExportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'ExcludeKeys', 'type': 'bool'}, + "export_blob_container_uri": {"key": "ExportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "ExcludeKeys", "type": "bool"}, } - def __init__( - self, - *, - export_blob_container_uri: str, - exclude_keys: bool, - **kwargs - ): + def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **kwargs): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -298,13 +281,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -328,95 +311,85 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'InputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'OutputBlobContainerUri', 'type': 'str'}, + "input_blob_container_uri": {"key": "InputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "OutputBlobContainerUri", "type": "str"}, } - def __init__( - self, - *, - input_blob_container_uri: str, - output_blob_container_uri: str, - **kwargs - ): + def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **kwargs): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -429,41 +402,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -484,45 +451,45 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] - :ivar subscriptionid: Required. The subscription identifier. + :ivar subscriptionid: The subscription identifier. Required. :vartype subscriptionid: str - :ivar resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. + :ivar resourcegroup: The name of the resource group that contains the IoT hub. A resource group + name uniquely identifies the resource group within the subscription. Required. :vartype resourcegroup: str :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: The properties of an IoT hub. :vartype properties: ~azure.mgmt.iothub.v2016_02_03.models.IotHubProperties - :ivar sku: Required. Information about the SKU of the IoT hub. + :ivar sku: Information about the SKU of the IoT hub. Required. :vartype sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'subscriptionid': {'required': True}, - 'resourcegroup': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "subscriptionid": {"required": True}, + "resourcegroup": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'subscriptionid': {'key': 'subscriptionid', 'type': 'str'}, - 'resourcegroup': {'key': 'resourcegroup', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "subscriptionid": {"key": "subscriptionid", "type": "str"}, + "resourcegroup": {"key": "resourcegroup", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( @@ -531,31 +498,31 @@ def __init__( location: str, subscriptionid: str, resourcegroup: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] - :keyword subscriptionid: Required. The subscription identifier. + :keyword subscriptionid: The subscription identifier. Required. :paramtype subscriptionid: str - :keyword resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. + :keyword resourcegroup: The name of the resource group that contains the IoT hub. A resource + group name uniquely identifies the resource group within the subscription. Required. :paramtype resourcegroup: str :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: The properties of an IoT hub. :paramtype properties: ~azure.mgmt.iothub.v2016_02_03.models.IotHubProperties - :keyword sku: Required. Information about the SKU of the IoT hub. + :keyword sku: Information about the SKU of the IoT hub. Required. :paramtype sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.subscriptionid = subscriptionid self.resourcegroup = resourcegroup self.etag = etag @@ -563,7 +530,7 @@ def __init__( self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -575,71 +542,60 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -681,44 +637,47 @@ class IotHubProperties(msrest.serialization.Model): DeviceIdentityOperations, FileUploadOperations. :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2016_02_03.models.OperationsMonitoringProperties - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2016_02_03.models.Capabilities """ _validation = { - 'provisioning_state': {'readonly': True}, - 'host_name': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "host_name": {"readonly": True}, } _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "operations_monitoring_properties": { + "key": "operationsMonitoringProperties", + "type": "OperationsMonitoringProperties", + }, + "features": {"key": "features", "type": "str"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - operations_monitoring_properties: Optional["OperationsMonitoringProperties"] = None, - features: Optional[Union[str, "Capabilities"]] = None, + operations_monitoring_properties: Optional["_models.OperationsMonitoringProperties"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -755,11 +714,11 @@ def __init__( DeviceIdentityOperations, FileUploadOperations. :paramtype operations_monitoring_properties: ~azure.mgmt.iothub.v2016_02_03.models.OperationsMonitoringProperties - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2016_02_03.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules self.provisioning_state = None @@ -774,7 +733,7 @@ def __init__( self.features = features -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -782,36 +741,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'current_value': {'key': 'CurrentValue', 'type': 'long'}, - 'max_value': {'key': 'MaxValue', 'type': 'long'}, + "name": {"key": "Name", "type": "str"}, + "current_value": {"key": "CurrentValue", "type": "int"}, + "max_value": {"key": "MaxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -823,30 +778,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -855,44 +805,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. Information about the SKU of the IoT hub. + :ivar sku: Information about the SKU of the IoT hub. Required. :vartype sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo - :ivar capacity: Required. IoT Hub capacity information. + :ivar capacity: IoT Hub capacity information. Required. :vartype capacity: ~azure.mgmt.iothub.v2016_02_03.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. Information about the SKU of the IoT hub. + :keyword sku: Information about the SKU of the IoT hub. Required. :paramtype sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo - :keyword capacity: Required. IoT Hub capacity information. + :keyword capacity: IoT Hub capacity information. Required. :paramtype capacity: ~azure.mgmt.iothub.v2016_02_03.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -904,129 +848,111 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", and "S3". :vartype name: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". + :ivar tier: The billing tier for the IoT hub. Known values are: "Free" and "Standard". :vartype tier: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuTier - :ivar capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :ivar capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. Required. + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'capacity': {'required': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "capacity": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: int, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: int, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", and "S3". :paramtype name: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSku - :keyword capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :keyword capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. Required. + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2016_02_03.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2016_02_03.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1037,12 +963,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2016_02_03.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2016_02_03.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1053,34 +979,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, } _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1091,7 +1013,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1103,30 +1025,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1142,13 +1059,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1171,44 +1088,39 @@ def __init__( See: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, + "name": {"key": "Name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationsMonitoringProperties(msrest.serialization.Model): +class OperationsMonitoringProperties(_serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations. :ivar events: Dictionary of :code:``. @@ -1217,127 +1129,118 @@ class OperationsMonitoringProperties(msrest.serialization.Model): """ _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, + "events": {"key": "events", "type": "{str}"}, } - def __init__( - self, - *, - events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, - **kwargs - ): + def __init__(self, *, events: Optional[Dict[str, Union[str, "_models.OperationMonitoringLevel"]]] = None, **kwargs): """ :keyword events: Dictionary of :code:``. :paramtype events: dict[str, str or ~azure.mgmt.iothub.v2016_02_03.models.OperationMonitoringLevel] """ - super(OperationsMonitoringProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.events = events -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2016_02_03.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2016_02_03.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1350,31 +1253,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -1383,23 +1281,23 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } def __init__( @@ -1415,14 +1313,14 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/__init__.py index e4c608fe7497..972b73cd63bb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/__init__.py @@ -8,6 +8,12 @@ from ._iot_hub_resource_operations import IotHubResourceOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'IotHubResourceOperations', + "IotHubResourceOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py index 3083dd943d56..7d38ebd127f3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,797 +6,704 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - api_version = "2016-02-03" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2016-02-03" - accept = "application/json, text/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-02-03" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - api_version = "2016-02-03" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - api_version = "2016-02-03" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2016_02_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2016_02_03.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -803,73 +711,169 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub to create or update. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub to create or update. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -878,12 +882,16 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub to create or update. + :param resource_name: The name of the IoT hub to create or update. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -895,111 +903,117 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub to delete. + :param resource_name: The name of the IoT hub to delete. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1009,90 +1023,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription - or ~azure.mgmt.iothub.v2016_02_03.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1106,7 +1126,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1116,56 +1138,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. :param resource_group_name: The name of the resource group that contains the IoT hubs. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1179,7 +1200,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1189,49 +1212,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1239,65 +1263,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1311,7 +1336,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1321,68 +1348,64 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable[str]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[str] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1396,7 +1419,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1406,57 +1431,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1464,61 +1491,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1526,61 +1556,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1591,60 +1624,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1658,7 +1688,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1668,55 +1700,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1724,65 +1756,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1796,7 +1829,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1806,50 +1841,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2016_02_03.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2016_02_03.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1857,67 +1946,68 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1931,7 +2021,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1941,55 +2033,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1997,24 +2091,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2023,39 +2118,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2016_02_03.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2016_02_03.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2063,24 +2244,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2089,39 +2271,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2016_02_03.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2016_02_03.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2016_02_03.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2129,12 +2397,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py index c1ed12f768d0..99d7a05ade1a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-01-19". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2017-01-19") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-01-19" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py index a2e342037f38..fca03a72d753 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import IotHubResourceOperations @@ -21,17 +21,21 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2017_01_19.operations.IotHubResourceOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-01-19". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -52,12 +56,7 @@ def __init__( self._serialize.client_side_validation = False self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -66,7 +65,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_metadata.json index 9b3b5dbac5c6..830a9225e6fd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py index 6eb13e4cb392..c0aa5275f93e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-01-19". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2017-01-19") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-01-19" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py index ce237e220a6e..a038374c6cd4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import IotHubResourceOperations @@ -21,18 +21,22 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2017_01_19.aio.operations.IotHubResourceOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-01-19". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -53,12 +57,7 @@ def __init__( self._serialize.client_side_validation = False self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -67,7 +66,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/__init__.py index e4c608fe7497..972b73cd63bb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/__init__.py @@ -8,6 +8,12 @@ from ._iot_hub_resource_operations import IotHubResourceOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'IotHubResourceOperations', + "IotHubResourceOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py index 2e28f6618b5a..500abcd9f330 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,114 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2017_01_19.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2017_01_19.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,73 +121,171 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub to create or update. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub to create or update. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -167,12 +294,16 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub to create or update. + :param resource_name: The name of the IoT hub to create or update. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -185,111 +316,117 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub to delete. + :param resource_name: The name of the IoT hub to delete. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -299,91 +436,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription or - ~azure.mgmt.iothub.v2017_01_19.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -397,7 +541,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,56 +553,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. :param resource_group_name: The name of the resource group that contains the IoT hubs. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -470,7 +618,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -480,49 +630,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -530,65 +683,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -602,7 +756,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -612,68 +768,64 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable[str]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[str] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -687,7 +839,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -697,57 +851,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -755,61 +911,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -817,61 +976,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -882,60 +1044,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -949,7 +1111,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -959,55 +1123,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1015,65 +1181,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1087,7 +1254,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1097,50 +1266,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2017_01_19.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2017_01_19.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] - _json = self._serialize.body(operation_inputs, 'OperationInputs') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1148,67 +1371,68 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1222,7 +1446,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,55 +1458,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1288,24 +1516,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1314,39 +1543,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2017_01_19.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2017_01_19.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1354,24 +1669,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1380,39 +1696,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2017_01_19.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2017_01_19.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1420,12 +1822,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/__init__.py index 00985acee0f9..d8247521ad65 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/__init__.py @@ -43,67 +43,69 @@ from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult from ._models_py3 import StorageEndpointProperties - -from ._iot_hub_client_enums import ( - AccessRights, - Capabilities, - IotHubNameUnavailabilityReason, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - OperationMonitoringLevel, - RoutingSource, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import OperationMonitoringLevel +from ._iot_hub_client_enums import RoutingSource +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CloudToDeviceProperties', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MessagingEndpointProperties', - 'OperationInputs', - 'OperationsMonitoringProperties', - 'RegistryStatistics', - 'Resource', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'AccessRights', - 'Capabilities', - 'IotHubNameUnavailabilityReason', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'OperationMonitoringLevel', - 'RoutingSource', + "CloudToDeviceProperties", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FallbackRouteProperties", + "FeedbackProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MessagingEndpointProperties", + "OperationInputs", + "OperationsMonitoringProperties", + "RegistryStatistics", + "Resource", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "AccessRights", + "Capabilities", + "IotHubNameUnavailabilityReason", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "OperationMonitoringLevel", + "RoutingSource", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py index 8c8854d1a75a..ab000036578c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,56 +27,58 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" S2 = "S2" S3 = "S3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -87,13 +87,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -102,18 +102,18 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operations monitoring level. - """ + +class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operations monitoring level.""" NONE = "None" ERROR = "Error" INFORMATION = "Information" ERROR_INFORMATION = "Error, Information" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" DEVICE_MESSAGES = "DeviceMessages" TWIN_CHANGE_EVENTS = "TwinChangeEvents" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py index 37c19eabd7ea..1992b2788ec3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -31,13 +33,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -45,7 +47,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -60,13 +62,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2017_01_19.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -82,36 +84,32 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'Code', 'type': 'str'}, - 'http_status_code': {'key': 'HttpStatusCode', 'type': 'str'}, - 'message': {'key': 'Message', 'type': 'str'}, - 'details': {'key': 'Details', 'type': 'str'}, + "code": {"key": "Code", "type": "str"}, + "http_status_code": {"key": "HttpStatusCode", "type": "str"}, + "message": {"key": "Message", "type": "str"}, + "details": {"key": "Details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. - :ivar tags: A set of tags. The tags. + :ivar tags: The tags. :vartype tags: dict[str, str] :ivar id: The Event Hub-compatible consumer group identifier. :vartype id: str @@ -120,34 +118,34 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags. + :keyword tags: The tags. :paramtype tags: dict[str, str] :keyword id: The Event Hub-compatible consumer group identifier. :paramtype id: str :keyword name: The Event Hub-compatible consumer group name. :paramtype name: str """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.id = id self.name = name -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -159,37 +157,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[str]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List[str]] = None, **kwargs): """ :keyword value: The array of Event Hub-compatible consumer group names. :paramtype value: list[str] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -203,36 +196,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -240,112 +229,106 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'ExportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'ExcludeKeys', 'type': 'bool'}, + "export_blob_container_uri": {"key": "ExportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "ExcludeKeys", "type": "bool"}, } - def __init__( - self, - *, - export_blob_container_uri: str, - exclude_keys: bool, - **kwargs - ): + def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **kwargs): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties related to the fallback route based on which the IoT hub routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source to which the routing rule is to be applied to. e.g. - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source to which the routing rule is to be applied to. e.g. DeviceMessages. + Required. Known values are: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", and + "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2017_01_19.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled or not. + :ivar is_enabled: Used to specify whether the fallback route is enabled or not. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword source: Required. The source to which the routing rule is to be applied to. e.g. - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source to which the routing rule is to be applied to. e.g. DeviceMessages. + Required. Known values are: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", and + "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2017_01_19.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled or not. + :keyword is_enabled: Used to specify whether the fallback route is enabled or not. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.condition = condition self.endpoint_names = endpoint_names self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -362,13 +345,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -392,95 +375,85 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'InputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'OutputBlobContainerUri', 'type': 'str'}, + "input_blob_container_uri": {"key": "InputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "OutputBlobContainerUri", "type": "str"}, } - def __init__( - self, - *, - input_blob_container_uri: str, - output_blob_container_uri: str, - **kwargs - ): + def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **kwargs): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -493,41 +466,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -548,45 +515,45 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] - :ivar subscriptionid: Required. The subscription identifier. + :ivar subscriptionid: The subscription identifier. Required. :vartype subscriptionid: str - :ivar resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. + :ivar resourcegroup: The name of the resource group that contains the IoT hub. A resource group + name uniquely identifies the resource group within the subscription. Required. :vartype resourcegroup: str :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: The properties of an IoT hub. :vartype properties: ~azure.mgmt.iothub.v2017_01_19.models.IotHubProperties - :ivar sku: Required. Information about the SKU of the IoT hub. + :ivar sku: Information about the SKU of the IoT hub. Required. :vartype sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'subscriptionid': {'required': True}, - 'resourcegroup': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "subscriptionid": {"required": True}, + "resourcegroup": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'subscriptionid': {'key': 'subscriptionid', 'type': 'str'}, - 'resourcegroup': {'key': 'resourcegroup', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "subscriptionid": {"key": "subscriptionid", "type": "str"}, + "resourcegroup": {"key": "resourcegroup", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( @@ -595,31 +562,31 @@ def __init__( location: str, subscriptionid: str, resourcegroup: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] - :keyword subscriptionid: Required. The subscription identifier. + :keyword subscriptionid: The subscription identifier. Required. :paramtype subscriptionid: str - :keyword resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. + :keyword resourcegroup: The name of the resource group that contains the IoT hub. A resource + group name uniquely identifies the resource group within the subscription. Required. :paramtype resourcegroup: str :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: The properties of an IoT hub. :paramtype properties: ~azure.mgmt.iothub.v2017_01_19.models.IotHubProperties - :keyword sku: Required. Information about the SKU of the IoT hub. + :keyword sku: Information about the SKU of the IoT hub. Required. :paramtype sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.subscriptionid = subscriptionid self.resourcegroup = resourcegroup self.etag = etag @@ -627,7 +594,7 @@ def __init__( self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -639,71 +606,60 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -749,46 +705,49 @@ class IotHubProperties(msrest.serialization.Model): TwinQueries, JobsOperations, DirectMethods. :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2017_01_19.models.OperationsMonitoringProperties - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2017_01_19.models.Capabilities """ _validation = { - 'provisioning_state': {'readonly': True}, - 'host_name': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "host_name": {"readonly": True}, } _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "operations_monitoring_properties": { + "key": "operationsMonitoringProperties", + "type": "OperationsMonitoringProperties", + }, + "features": {"key": "features", "type": "str"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - operations_monitoring_properties: Optional["OperationsMonitoringProperties"] = None, - features: Optional[Union[str, "Capabilities"]] = None, + operations_monitoring_properties: Optional["_models.OperationsMonitoringProperties"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -829,11 +788,11 @@ def __init__( TwinQueries, JobsOperations, DirectMethods. :paramtype operations_monitoring_properties: ~azure.mgmt.iothub.v2017_01_19.models.OperationsMonitoringProperties - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2017_01_19.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules self.provisioning_state = None @@ -849,7 +808,7 @@ def __init__( self.features = features -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -857,36 +816,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'current_value': {'key': 'CurrentValue', 'type': 'long'}, - 'max_value': {'key': 'MaxValue', 'type': 'long'}, + "name": {"key": "Name", "type": "str"}, + "current_value": {"key": "CurrentValue", "type": "int"}, + "max_value": {"key": "MaxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -898,30 +853,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -930,44 +880,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. Information about the SKU of the IoT hub. + :ivar sku: Information about the SKU of the IoT hub. Required. :vartype sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo - :ivar capacity: Required. IoT Hub capacity information. + :ivar capacity: IoT Hub capacity information. Required. :vartype capacity: ~azure.mgmt.iothub.v2017_01_19.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. Information about the SKU of the IoT hub. + :keyword sku: Information about the SKU of the IoT hub. Required. :paramtype sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo - :keyword capacity: Required. IoT Hub capacity information. + :keyword capacity: IoT Hub capacity information. Required. :paramtype capacity: ~azure.mgmt.iothub.v2017_01_19.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -979,129 +923,111 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", and "S3". :vartype name: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". + :ivar tier: The billing tier for the IoT hub. Known values are: "Free" and "Standard". :vartype tier: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuTier - :ivar capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :ivar capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. Required. + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'capacity': {'required': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "capacity": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: int, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: int, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", and "S3". :paramtype name: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSku - :keyword capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :keyword capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. Required. + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2017_01_19.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2017_01_19.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1112,12 +1038,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2017_01_19.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2017_01_19.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1128,34 +1054,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, } _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1166,7 +1088,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1178,30 +1100,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1217,13 +1134,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1246,44 +1163,39 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, + "name": {"key": "Name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationsMonitoringProperties(msrest.serialization.Model): +class OperationsMonitoringProperties(_serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. :ivar events: Dictionary of :code:``. @@ -1292,129 +1204,120 @@ class OperationsMonitoringProperties(msrest.serialization.Model): """ _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, + "events": {"key": "events", "type": "{str}"}, } - def __init__( - self, - *, - events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, - **kwargs - ): + def __init__(self, *, events: Optional[Dict[str, Union[str, "_models.OperationMonitoringLevel"]]] = None, **kwargs): """ :keyword events: Dictionary of :code:``. :paramtype events: dict[str, str or ~azure.mgmt.iothub.v2017_01_19.models.OperationMonitoringLevel] """ - super(OperationsMonitoringProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.events = events -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", and + "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2017_01_19.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", and + "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2017_01_19.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -1422,7 +1325,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -1439,17 +1342,17 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, **kwargs ): """ @@ -1465,23 +1368,23 @@ def __init__( the routing rules. This list does not include the built-in Event Hubs endpoint. :paramtype event_hubs: list[~azure.mgmt.iothub.v2017_01_19.models.RoutingEventHubProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the event hub endpoint. + :ivar connection_string: The connection string of the event hub endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name of the event hub endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved; events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :ivar name: The name of the event hub endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved; events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -1490,15 +1393,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -1511,26 +1414,26 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the event hub endpoint. + :keyword connection_string: The connection string of the event hub endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name of the event hub endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved; events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :keyword name: The name of the event hub endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved; events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -1550,17 +1453,17 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, **kwargs ): """ @@ -1579,24 +1482,24 @@ def __init__( specified in the 'routes' section get routed to the built-in eventhub endpoint. :paramtype fallback_route: ~azure.mgmt.iothub.v2017_01_19.models.FallbackRouteProperties """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :ivar connection_string: The connection string of the service bus queue endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name of the service bus queue endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved; events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. + :ivar name: The name of the service bus queue endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved; events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -1605,15 +1508,15 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -1626,38 +1529,38 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :keyword connection_string: The connection string of the service bus queue endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name of the service bus queue endpoint. The name can only include + :keyword name: The name of the service bus queue endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved; events, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. + not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :ivar connection_string: The connection string of the service bus topic endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name of the service bus topic endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved; events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. + :ivar name: The name of the service bus topic endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved; events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual topic name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -1666,15 +1569,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -1687,92 +1590,92 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :keyword connection_string: The connection string of the service bus topic endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name of the service bus topic endpoint. The name can only include + :keyword name: The name of the service bus topic endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved; events, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. + need not be the same as the actual topic name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2017_01_19.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2017_01_19.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1785,31 +1688,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -1818,23 +1716,23 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } def __init__( @@ -1850,14 +1748,14 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/__init__.py index e4c608fe7497..972b73cd63bb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/__init__.py @@ -8,6 +8,12 @@ from ._iot_hub_resource_operations import IotHubResourceOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'IotHubResourceOperations', + "IotHubResourceOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py index 9a3c7727f484..b23a7e69bdf3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,797 +6,704 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2017-01-19" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2017-01-19" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-01-19" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2017-01-19" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2017-01-19" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2017_01_19.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2017_01_19.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -803,73 +711,169 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub to create or update. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub to create or update. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -878,12 +882,16 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub to create or update. + :param resource_name: The name of the IoT hub to create or update. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -895,111 +903,117 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub to delete. + :param resource_name: The name of the IoT hub to delete. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1009,90 +1023,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription - or ~azure.mgmt.iothub.v2017_01_19.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1106,7 +1126,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1116,56 +1138,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. :param resource_group_name: The name of the resource group that contains the IoT hubs. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1179,7 +1200,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1189,49 +1212,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1239,65 +1263,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1311,7 +1336,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1321,68 +1348,64 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable[str]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[str] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1396,7 +1419,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1406,57 +1431,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1464,61 +1491,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1526,61 +1556,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1591,60 +1624,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1658,7 +1688,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1668,55 +1700,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1724,65 +1756,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1796,7 +1829,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1806,50 +1841,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2017_01_19.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2017_01_19.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1857,67 +1946,68 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1931,7 +2021,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1941,55 +2033,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1997,24 +2091,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2023,39 +2118,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2017_01_19.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2017_01_19.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2063,24 +2244,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2089,39 +2271,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2017_01_19.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2017_01_19.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_01_19.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2129,12 +2397,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py index 5ce009af8fd1..2947099a69ae 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2017-07-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-07-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py index 4414b0b4414f..53e686df05f1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import CertificatesOperations, IotHubResourceOperations, Operations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -30,12 +31,15 @@ class IotHubClient: :vartype iot_hub_resource: azure.mgmt.iothub.v2017_07_01.operations.IotHubResourceOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2017_07_01.operations.CertificatesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -58,12 +62,7 @@ def __init__( self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -72,7 +71,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_metadata.json index 5f98b61d4d1d..378c3f3428bb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py index 40d8ab7b9521..20d6b03ad869 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2017-07-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-07-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py index bee6ec61f9b1..ae7f15087c1d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import CertificatesOperations, IotHubResourceOperations, Operations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -31,12 +32,15 @@ class IotHubClient: azure.mgmt.iothub.v2017_07_01.aio.operations.IotHubResourceOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2017_07_01.aio.operations.CertificatesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -59,12 +63,7 @@ def __init__( self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -73,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/__init__.py index 824bf6a80df3..2b2483f833aa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._iot_hub_resource_operations import IotHubResourceOperations from ._certificates_operations import CertificatesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'CertificatesOperations', + "Operations", + "IotHubResourceOperations", + "CertificatesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py index 4b86305ff88d..036dd72277c3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2017_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2017_07_01.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2017_07_01.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2017_07_01.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py index aba209624d8d..d80a2a66e6a3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,114 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2017_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2017_07_01.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +121,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +305,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,112 +330,118 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -306,91 +451,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription or - ~azure.mgmt.iothub.v2017_07_01.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -404,7 +556,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,56 +568,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -477,7 +632,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -487,49 +644,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -537,65 +697,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -609,7 +770,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -619,68 +782,64 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable[str]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[str] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -694,7 +853,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -704,57 +865,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -762,61 +925,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -824,61 +990,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -889,60 +1058,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -956,7 +1125,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -966,55 +1137,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1022,65 +1195,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1094,7 +1268,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1104,50 +1280,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2017_07_01.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. - _json = self._serialize.body(operation_inputs, 'OperationInputs') + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2017_07_01.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1155,67 +1385,68 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1229,7 +1460,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1239,55 +1472,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1295,24 +1530,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1321,39 +1557,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2017_07_01.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2017_07_01.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1361,24 +1683,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1387,39 +1710,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2017_07_01.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2017_07_01.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1427,12 +1836,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py index a0cc31207e31..35da389e046e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2017_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2017_07_01.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/__init__.py index 54511d29bce7..01c5f1df9068 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/__init__.py @@ -54,78 +54,80 @@ from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult from ._models_py3 import StorageEndpointProperties - -from ._iot_hub_client_enums import ( - AccessRights, - Capabilities, - IotHubNameUnavailabilityReason, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - OperationMonitoringLevel, - RoutingSource, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import OperationMonitoringLevel +from ._iot_hub_client_enums import RoutingSource +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MessagingEndpointProperties', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'OperationsMonitoringProperties', - 'RegistryStatistics', - 'Resource', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'AccessRights', - 'Capabilities', - 'IotHubNameUnavailabilityReason', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'OperationMonitoringLevel', - 'RoutingSource', + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FallbackRouteProperties", + "FeedbackProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MessagingEndpointProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "OperationsMonitoringProperties", + "RegistryStatistics", + "Resource", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "AccessRights", + "Capabilities", + "IotHubNameUnavailabilityReason", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "OperationMonitoringLevel", + "RoutingSource", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py index 8c8854d1a75a..ab000036578c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,56 +27,58 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" S2 = "S2" S3 = "S3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -87,13 +87,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -102,18 +102,18 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operations monitoring level. - """ + +class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operations monitoring level.""" NONE = "None" ERROR = "Error" INFORMATION = "Information" ERROR_INFORMATION = "Error, Information" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" DEVICE_MESSAGES = "DeviceMessages" TWIN_CHANGE_EVENTS = "TwinChangeEvents" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py index dd94caccf791..e9c93415c67f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -24,25 +26,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -60,31 +57,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2017_07_01.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -92,7 +84,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -100,24 +92,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,30 +124,26 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -169,7 +152,7 @@ def __init__( self.updated = None -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -192,32 +175,28 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -227,7 +206,7 @@ def __init__( self.verification_code = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -236,25 +215,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -273,32 +247,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2017_07_01.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -306,7 +275,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -322,13 +291,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -336,7 +305,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -351,13 +320,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2017_07_01.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -373,36 +342,32 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'Code', 'type': 'str'}, - 'http_status_code': {'key': 'HttpStatusCode', 'type': 'str'}, - 'message': {'key': 'Message', 'type': 'str'}, - 'details': {'key': 'Details', 'type': 'str'}, + "code": {"key": "Code", "type": "str"}, + "http_status_code": {"key": "HttpStatusCode", "type": "str"}, + "message": {"key": "Message", "type": "str"}, + "details": {"key": "Details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. - :ivar tags: A set of tags. The tags. + :ivar tags: The tags. :vartype tags: dict[str, str] :ivar id: The Event Hub-compatible consumer group identifier. :vartype id: str @@ -411,34 +376,34 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags. + :keyword tags: The tags. :paramtype tags: dict[str, str] :keyword id: The Event Hub-compatible consumer group identifier. :paramtype id: str :keyword name: The Event Hub-compatible consumer group name. :paramtype name: str """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.id = id self.name = name -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -450,37 +415,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[str]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List[str]] = None, **kwargs): """ :keyword value: The array of Event Hub-compatible consumer group names. :paramtype value: list[str] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -494,36 +454,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -531,112 +487,106 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'ExportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'ExcludeKeys', 'type': 'bool'}, + "export_blob_container_uri": {"key": "ExportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "ExcludeKeys", "type": "bool"}, } - def __init__( - self, - *, - export_blob_container_uri: str, - exclude_keys: bool, - **kwargs - ): + def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **kwargs): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2017_07_01.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2017_07_01.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.condition = condition self.endpoint_names = endpoint_names self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -653,13 +603,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -683,95 +633,85 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'InputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'OutputBlobContainerUri', 'type': 'str'}, + "input_blob_container_uri": {"key": "InputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "OutputBlobContainerUri", "type": "str"}, } - def __init__( - self, - *, - input_blob_container_uri: str, - output_blob_container_uri: str, - **kwargs - ): + def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **kwargs): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -784,41 +724,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -839,45 +773,45 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] - :ivar subscriptionid: Required. The subscription identifier. + :ivar subscriptionid: The subscription identifier. Required. :vartype subscriptionid: str - :ivar resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. + :ivar resourcegroup: The name of the resource group that contains the IoT hub. A resource group + name uniquely identifies the resource group within the subscription. Required. :vartype resourcegroup: str :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: The properties of an IoT hub. :vartype properties: ~azure.mgmt.iothub.v2017_07_01.models.IotHubProperties - :ivar sku: Required. Information about the SKU of the IoT hub. + :ivar sku: Information about the SKU of the IoT hub. Required. :vartype sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'subscriptionid': {'required': True}, - 'resourcegroup': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "subscriptionid": {"required": True}, + "resourcegroup": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'subscriptionid': {'key': 'subscriptionid', 'type': 'str'}, - 'resourcegroup': {'key': 'resourcegroup', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "subscriptionid": {"key": "subscriptionid", "type": "str"}, + "resourcegroup": {"key": "resourcegroup", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( @@ -886,31 +820,31 @@ def __init__( location: str, subscriptionid: str, resourcegroup: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] - :keyword subscriptionid: Required. The subscription identifier. + :keyword subscriptionid: The subscription identifier. Required. :paramtype subscriptionid: str - :keyword resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. + :keyword resourcegroup: The name of the resource group that contains the IoT hub. A resource + group name uniquely identifies the resource group within the subscription. Required. :paramtype resourcegroup: str :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: The properties of an IoT hub. :paramtype properties: ~azure.mgmt.iothub.v2017_07_01.models.IotHubProperties - :keyword sku: Required. Information about the SKU of the IoT hub. + :keyword sku: Information about the SKU of the IoT hub. Required. :paramtype sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.subscriptionid = subscriptionid self.resourcegroup = resourcegroup self.etag = etag @@ -918,7 +852,7 @@ def __init__( self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -930,71 +864,60 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1040,46 +963,49 @@ class IotHubProperties(msrest.serialization.Model): TwinQueries, JobsOperations, DirectMethods. :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2017_07_01.models.OperationsMonitoringProperties - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2017_07_01.models.Capabilities """ _validation = { - 'provisioning_state': {'readonly': True}, - 'host_name': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "host_name": {"readonly": True}, } _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "operations_monitoring_properties": { + "key": "operationsMonitoringProperties", + "type": "OperationsMonitoringProperties", + }, + "features": {"key": "features", "type": "str"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - operations_monitoring_properties: Optional["OperationsMonitoringProperties"] = None, - features: Optional[Union[str, "Capabilities"]] = None, + operations_monitoring_properties: Optional["_models.OperationsMonitoringProperties"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1120,11 +1046,11 @@ def __init__( TwinQueries, JobsOperations, DirectMethods. :paramtype operations_monitoring_properties: ~azure.mgmt.iothub.v2017_07_01.models.OperationsMonitoringProperties - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2017_07_01.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules self.provisioning_state = None @@ -1140,7 +1066,7 @@ def __init__( self.features = features -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1148,36 +1074,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'current_value': {'key': 'CurrentValue', 'type': 'long'}, - 'max_value': {'key': 'MaxValue', 'type': 'long'}, + "name": {"key": "Name", "type": "str"}, + "current_value": {"key": "CurrentValue", "type": "int"}, + "max_value": {"key": "MaxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1189,30 +1111,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1221,44 +1138,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. Information about the SKU of the IoT hub. + :ivar sku: Information about the SKU of the IoT hub. Required. :vartype sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo - :ivar capacity: Required. IoT Hub capacity information. + :ivar capacity: IoT Hub capacity information. Required. :vartype capacity: ~azure.mgmt.iothub.v2017_07_01.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. Information about the SKU of the IoT hub. + :keyword sku: Information about the SKU of the IoT hub. Required. :paramtype sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo - :keyword capacity: Required. IoT Hub capacity information. + :keyword capacity: IoT Hub capacity information. Required. :paramtype capacity: ~azure.mgmt.iothub.v2017_07_01.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1270,129 +1181,111 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", and "S3". :vartype name: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". + :ivar tier: The billing tier for the IoT hub. Known values are: "Free" and "Standard". :vartype tier: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuTier - :ivar capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :ivar capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. Required. + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'capacity': {'required': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "capacity": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: int, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: int, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", and "S3". :paramtype name: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSku - :keyword capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :keyword capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. Required. + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2017_07_01.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2017_07_01.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1403,12 +1296,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2017_07_01.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2017_07_01.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1419,34 +1312,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, } _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1457,7 +1346,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1469,30 +1358,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1508,13 +1392,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1537,13 +1421,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1555,30 +1439,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2017_07_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1592,61 +1471,52 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, + "name": {"key": "Name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1658,27 +1528,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationsMonitoringProperties(msrest.serialization.Model): +class OperationsMonitoringProperties(_serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. :ivar events: Dictionary of :code:``. @@ -1687,129 +1553,120 @@ class OperationsMonitoringProperties(msrest.serialization.Model): """ _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, + "events": {"key": "events", "type": "{str}"}, } - def __init__( - self, - *, - events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, - **kwargs - ): + def __init__(self, *, events: Optional[Dict[str, Union[str, "_models.OperationMonitoringLevel"]]] = None, **kwargs): """ :keyword events: Dictionary of :code:``. :paramtype events: dict[str, str or ~azure.mgmt.iothub.v2017_07_01.models.OperationMonitoringLevel] """ - super(OperationsMonitoringProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.events = events -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", and + "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2017_07_01.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", and + "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2017_07_01.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -1817,7 +1674,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -1838,19 +1695,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -1870,24 +1727,24 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2017_07_01.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the event hub endpoint. + :ivar connection_string: The connection string of the event hub endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -1896,15 +1753,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -1917,26 +1774,26 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the event hub endpoint. + :keyword connection_string: The connection string of the event hub endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -1956,17 +1813,17 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, **kwargs ): """ @@ -1985,24 +1842,24 @@ def __init__( specified in the 'routes' section get routed to the built-in eventhub endpoint. :paramtype fallback_route: ~azure.mgmt.iothub.v2017_07_01.models.FallbackRouteProperties """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :ivar connection_string: The connection string of the service bus queue endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -2011,15 +1868,15 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2032,38 +1889,38 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :keyword connection_string: The connection string of the service bus queue endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :ivar connection_string: The connection string of the service bus topic endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual topic name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -2072,15 +1929,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2093,43 +1950,43 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :keyword connection_string: The connection string of the service bus topic endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual topic name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the storage account. + :ivar connection_string: The connection string of the storage account. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2147,23 +2004,23 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -2181,18 +2038,18 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the storage account. + :keyword connection_string: The connection string of the storage account. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2208,7 +2065,7 @@ def __init__( 'avro' and 'avroDeflate'. Default value is 'avro'. :paramtype encoding: str """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id @@ -2220,72 +2077,72 @@ def __init__( self.encoding = encoding -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2017_07_01.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2017_07_01.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2298,31 +2155,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -2331,23 +2183,23 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } def __init__( @@ -2363,14 +2215,14 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/__init__.py index 824bf6a80df3..2b2483f833aa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._iot_hub_resource_operations import IotHubResourceOperations from ._certificates_operations import CertificatesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'CertificatesOperations', + "Operations", + "IotHubResourceOperations", + "CertificatesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py index 18cb73c3bed8..1b3302d58064 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2017-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2017-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2017_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2017_07_01.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2017_07_01.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2017_07_01.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py index 91c889db3eb2..c338275aa177 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,800 +6,706 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2017-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2017-07-01" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2017-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2017-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2017_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2017_07_01.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -806,76 +713,180 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -884,15 +895,19 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -904,112 +919,118 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1019,90 +1040,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription - or ~azure.mgmt.iothub.v2017_07_01.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1116,7 +1143,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1126,56 +1155,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1189,7 +1216,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1199,49 +1228,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1249,65 +1279,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1321,7 +1352,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1331,68 +1364,64 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable[str]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[str] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1406,7 +1435,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1416,57 +1447,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1474,61 +1507,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1536,61 +1572,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1601,60 +1640,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1668,7 +1704,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1678,55 +1716,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1734,65 +1772,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1806,7 +1845,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1816,50 +1857,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2017_07_01.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2017_07_01.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1867,67 +1962,68 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1941,7 +2037,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1951,55 +2049,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2007,24 +2107,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2033,39 +2134,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2017_07_01.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2017_07_01.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2073,24 +2260,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2099,39 +2287,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2017_07_01.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2017_07_01.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2139,12 +2413,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py index 6c4cffa23041..dccf836e7004 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2017-07-01" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2017_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2017_07_01.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py index f55c34e1de97..239ccd525137 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-01-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2018-01-22") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-01-22" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py index 68bffdac7958..268e8ee0eb2b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import CertificatesOperations, IotHubResourceOperations, Operations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -30,12 +31,15 @@ class IotHubClient: :vartype iot_hub_resource: azure.mgmt.iothub.v2018_01_22.operations.IotHubResourceOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2018_01_22.operations.CertificatesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-01-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -58,12 +62,7 @@ def __init__( self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -72,7 +71,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_metadata.json index e2500d28a681..8b3efc0dcd35 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py index a3da587edd4f..882a8161e308 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-01-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2018-01-22") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-01-22" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py index ea05376c5fae..885f9db7bbc9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import CertificatesOperations, IotHubResourceOperations, Operations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -31,12 +32,15 @@ class IotHubClient: azure.mgmt.iothub.v2018_01_22.aio.operations.IotHubResourceOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2018_01_22.aio.operations.CertificatesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-01-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -59,12 +63,7 @@ def __init__( self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -73,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/__init__.py index 824bf6a80df3..2b2483f833aa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._iot_hub_resource_operations import IotHubResourceOperations from ._certificates_operations import CertificatesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'CertificatesOperations', + "Operations", + "IotHubResourceOperations", + "CertificatesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py index ee30cb4164b2..5ac3bd2b2cf8 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_01_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_01_22.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2018_01_22.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2018_01_22.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py index 6326463e758e..dc7a05ab0fcc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_01_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_01_22.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +122,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +306,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +331,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2018_01_22.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +470,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2018_01_22.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +661,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription or - ~azure.mgmt.iothub.v2018_01_22.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +766,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +778,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +842,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +854,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +907,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +980,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +992,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1065,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1077,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,61 +1137,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,61 +1202,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1008,60 +1270,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1075,7 +1337,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1085,55 +1349,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1141,65 +1407,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1213,7 +1480,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1223,50 +1492,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2018_01_22.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2018_01_22.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1274,67 +1597,68 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1348,7 +1672,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1358,55 +1684,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1414,24 +1742,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1440,39 +1769,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2018_01_22.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2018_01_22.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1480,24 +1895,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1506,39 +1922,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2018_01_22.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2018_01_22.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1546,12 +2048,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py index a0f3e84a084b..eda95b8d8884 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_01_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_01_22.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/__init__.py index 30257e59af2f..678e384ef856 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/__init__.py @@ -55,79 +55,81 @@ from ._models_py3 import StorageEndpointProperties from ._models_py3 import TagsResource - -from ._iot_hub_client_enums import ( - AccessRights, - Capabilities, - IotHubNameUnavailabilityReason, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - OperationMonitoringLevel, - RoutingSource, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import OperationMonitoringLevel +from ._iot_hub_client_enums import RoutingSource +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MessagingEndpointProperties', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'OperationsMonitoringProperties', - 'RegistryStatistics', - 'Resource', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'AccessRights', - 'Capabilities', - 'IotHubNameUnavailabilityReason', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'OperationMonitoringLevel', - 'RoutingSource', + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FallbackRouteProperties", + "FeedbackProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MessagingEndpointProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "OperationsMonitoringProperties", + "RegistryStatistics", + "Resource", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "AccessRights", + "Capabilities", + "IotHubNameUnavailabilityReason", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "OperationMonitoringLevel", + "RoutingSource", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py index 8c8854d1a75a..ab000036578c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,56 +27,58 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" S2 = "S2" S3 = "S3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -87,13 +87,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -102,18 +102,18 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operations monitoring level. - """ + +class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operations monitoring level.""" NONE = "None" ERROR = "Error" INFORMATION = "Information" ERROR_INFORMATION = "Error, Information" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" DEVICE_MESSAGES = "DeviceMessages" TWIN_CHANGE_EVENTS = "TwinChangeEvents" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py index b3c1a0c63993..0747e4c2a15f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -24,25 +26,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -60,31 +57,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2018_01_22.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -92,7 +84,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -100,24 +92,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,30 +124,26 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -169,7 +152,7 @@ def __init__( self.updated = None -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -192,32 +175,28 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -227,7 +206,7 @@ def __init__( self.verification_code = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -236,25 +215,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -273,32 +247,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2018_01_22.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -306,7 +275,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -322,13 +291,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -336,7 +305,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -351,13 +320,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2018_01_22.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -373,33 +342,29 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -417,31 +382,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, str] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -449,7 +409,7 @@ def __init__( self.etag = None -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -461,37 +421,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -505,36 +460,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -542,48 +493,42 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, } - def __init__( - self, - *, - export_blob_container_uri: str, - exclude_keys: bool, - **kwargs - ): + def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **kwargs): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -591,39 +536,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2018_01_22.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -634,21 +579,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2018_01_22.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -656,7 +601,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -673,13 +618,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -703,95 +648,85 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, } - def __init__( - self, - *, - input_blob_container_uri: str, - output_blob_container_uri: str, - **kwargs - ): + def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **kwargs): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -804,41 +739,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -859,68 +788,68 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: The properties of an IoT hub. :vartype properties: ~azure.mgmt.iothub.v2018_01_22.models.IotHubProperties - :ivar sku: Required. Information about the SKU of the IoT hub. + :ivar sku: Information about the SKU of the IoT hub. Required. :vartype sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: The properties of an IoT hub. :paramtype properties: ~azure.mgmt.iothub.v2018_01_22.models.IotHubProperties - :keyword sku: Required. Information about the SKU of the IoT hub. + :keyword sku: Information about the SKU of the IoT hub. Required. :paramtype sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -932,71 +861,60 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1044,48 +962,51 @@ class IotHubProperties(msrest.serialization.Model): TwinQueries, JobsOperations, DirectMethods. :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2018_01_22.models.OperationsMonitoringProperties - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2018_01_22.models.Capabilities """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, } _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "operations_monitoring_properties": { + "key": "operationsMonitoringProperties", + "type": "OperationsMonitoringProperties", + }, + "features": {"key": "features", "type": "str"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - operations_monitoring_properties: Optional["OperationsMonitoringProperties"] = None, - features: Optional[Union[str, "Capabilities"]] = None, + operations_monitoring_properties: Optional["_models.OperationsMonitoringProperties"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1126,11 +1047,11 @@ def __init__( TwinQueries, JobsOperations, DirectMethods. :paramtype operations_monitoring_properties: ~azure.mgmt.iothub.v2018_01_22.models.OperationsMonitoringProperties - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2018_01_22.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules self.provisioning_state = None @@ -1147,7 +1068,7 @@ def __init__( self.features = features -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1155,36 +1076,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1196,30 +1113,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1228,44 +1140,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo - :ivar capacity: Required. IoT Hub capacity information. + :ivar capacity: IoT Hub capacity information. Required. :vartype capacity: ~azure.mgmt.iothub.v2018_01_22.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo - :keyword capacity: Required. IoT Hub capacity information. + :keyword capacity: IoT Hub capacity information. Required. :paramtype capacity: ~azure.mgmt.iothub.v2018_01_22.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1277,128 +1183,110 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", and "S3". :vartype name: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". + :ivar tier: The billing tier for the IoT hub. Known values are: "Free" and "Standard". :vartype tier: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", and "S3". :paramtype name: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2018_01_22.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2018_01_22.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1409,12 +1297,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2018_01_22.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2018_01_22.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1425,34 +1313,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, } _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1463,7 +1347,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1475,30 +1359,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1514,13 +1393,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1543,13 +1422,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1561,30 +1440,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2018_01_22.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1598,61 +1472,52 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1664,27 +1529,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationsMonitoringProperties(msrest.serialization.Model): +class OperationsMonitoringProperties(_serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. :ivar events: Dictionary of :code:``. @@ -1693,129 +1554,120 @@ class OperationsMonitoringProperties(msrest.serialization.Model): """ _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, + "events": {"key": "events", "type": "{str}"}, } - def __init__( - self, - *, - events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, - **kwargs - ): + def __init__(self, *, events: Optional[Dict[str, Union[str, "_models.OperationMonitoringLevel"]]] = None, **kwargs): """ :keyword events: Dictionary of :code:``. :paramtype events: dict[str, str or ~azure.mgmt.iothub.v2018_01_22.models.OperationMonitoringLevel] """ - super(OperationsMonitoringProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.events = events -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", and + "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2018_01_22.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", and + "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2018_01_22.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -1823,7 +1675,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -1844,19 +1696,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -1876,24 +1728,24 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2018_01_22.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the event hub endpoint. + :ivar connection_string: The connection string of the event hub endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -1902,15 +1754,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -1923,26 +1775,26 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the event hub endpoint. + :keyword connection_string: The connection string of the event hub endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -1962,17 +1814,17 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, **kwargs ): """ @@ -1991,24 +1843,24 @@ def __init__( specified in the 'routes' section get routed to the built-in eventhub endpoint. :paramtype fallback_route: ~azure.mgmt.iothub.v2018_01_22.models.FallbackRouteProperties """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :ivar connection_string: The connection string of the service bus queue endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -2017,15 +1869,15 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2038,38 +1890,38 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :keyword connection_string: The connection string of the service bus queue endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :ivar connection_string: The connection string of the service bus topic endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual topic name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -2078,15 +1930,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2099,43 +1951,43 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :keyword connection_string: The connection string of the service bus topic endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual topic name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the storage account. + :ivar connection_string: The connection string of the storage account. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2153,23 +2005,23 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -2187,18 +2039,18 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the storage account. + :keyword connection_string: The connection string of the storage account. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2214,7 +2066,7 @@ def __init__( 'avro' and 'avroDeflate'. Default value is 'avro'. :paramtype encoding: str """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id @@ -2226,72 +2078,72 @@ def __init__( self.encoding = encoding -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2018_01_22.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2018_01_22.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2304,31 +2156,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -2337,23 +2184,23 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } def __init__( @@ -2369,39 +2216,34 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/__init__.py index 824bf6a80df3..2b2483f833aa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/__init__.py @@ -10,8 +10,14 @@ from ._iot_hub_resource_operations import IotHubResourceOperations from ._certificates_operations import CertificatesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'CertificatesOperations', + "Operations", + "IotHubResourceOperations", + "CertificatesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py index 0ff51fe8a7db..cb0042274dce 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-01-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-01-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_01_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_01_22.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2018_01_22.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2018_01_22.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py index c563c9fa4cbe..83474e2a8047 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,844 +6,740 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-01-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-01-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2018-01-22" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-01-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-01-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_01_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_01_22.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -850,76 +747,180 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -928,15 +929,19 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -948,114 +953,133 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2018_01_22.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1067,111 +1091,186 @@ def begin_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2018_01_22.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1181,90 +1280,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription - or ~azure.mgmt.iothub.v2018_01_22.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1278,7 +1383,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1288,56 +1395,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1351,7 +1456,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1361,49 +1468,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1411,65 +1519,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - else: - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=next_link, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1483,7 +1592,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1493,68 +1604,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1568,7 +1677,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1578,57 +1689,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1636,61 +1749,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1698,61 +1814,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1763,60 +1882,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1830,7 +1946,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1840,55 +1958,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1896,65 +2014,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1968,7 +2087,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1978,50 +2099,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2018_01_22.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2018_01_22.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2029,67 +2204,68 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2103,7 +2279,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2113,55 +2291,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2169,24 +2349,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2195,39 +2376,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2018_01_22.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2018_01_22.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2235,24 +2502,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2261,39 +2529,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2018_01_22.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2018_01_22.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2301,12 +2655,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py index b03fd6ba6885..cd5750cd03c3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2018-01-22" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_01_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_01_22.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py index b769e14330dc..1514d2e1159e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2018-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-04-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py index 90c47669ff17..e22396a3c956 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import CertificatesOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -33,12 +34,15 @@ class IotHubClient: azure.mgmt.iothub.v2018_04_01.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2018_04_01.operations.CertificatesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -59,15 +63,12 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -76,7 +77,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_metadata.json index 77f57a51f86f..4a82cf4b544a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py index 33025dfbeb4b..c3520a092864 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2018-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-04-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py index e6b9814e84cf..937aca447b75 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration from .operations import CertificatesOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -34,12 +35,15 @@ class IotHubClient: azure.mgmt.iothub.v2018_04_01.aio.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2018_04_01.aio.operations.CertificatesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -60,15 +64,12 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,7 +78,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/__init__.py index 68f403afba22..64c35ba588b5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/__init__.py @@ -11,9 +11,15 @@ from ._resource_provider_common_operations import ResourceProviderCommonOperations from ._certificates_operations import CertificatesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py index b49828f49c8b..d8d313117e32 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_04_01.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2018_04_01.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2018_04_01.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py index cc101dda0373..a338b637ea03 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_04_01.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +125,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +309,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +334,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2018_04_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +473,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2018_04_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +664,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription or - ~azure.mgmt.iothub.v2018_04_01.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +769,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +781,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +845,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +857,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +910,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +983,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +995,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1068,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1080,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,61 +1140,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,61 +1205,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1008,60 +1273,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1075,7 +1340,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1085,55 +1352,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1141,65 +1410,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1213,7 +1483,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1223,61 +1495,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1291,7 +1562,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,50 +1574,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2018_04_01.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2018_04_01.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] - _json = self._serialize.body(operation_inputs, 'OperationInputs') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1352,61 +1679,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] - _json = self._serialize.body(input, 'TestAllRoutesInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1414,61 +1812,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] - _json = self._serialize.body(input, 'TestRouteInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1476,67 +1945,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1550,7 +2020,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1560,55 +2032,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,24 +2090,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1642,39 +2117,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2018_04_01.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2018_04_01.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1682,24 +2243,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1708,39 +2270,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2018_04_01.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2018_04_01.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1748,12 +2396,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py index dafdb8c83729..9f2389ff551a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_04_01.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py index b13bd6e0238b..a16230bf0ab5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_04_01.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/__init__.py index ab7ebbb14918..0c50a358af8e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/__init__.py @@ -72,102 +72,104 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - Capabilities, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - OperationMonitoringLevel, - RouteErrorSeverity, - RoutingSource, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import OperationMonitoringLevel +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'OperationsMonitoringProperties', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'Capabilities', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'OperationMonitoringLevel', - 'RouteErrorSeverity', - 'RoutingSource', - 'TestResultStatus', + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FallbackRouteProperties", + "FeedbackProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "OperationsMonitoringProperties", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "Capabilities", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "OperationMonitoringLevel", + "RouteErrorSeverity", + "RoutingSource", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py index 0ee5551a863e..6331d5811554 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,42 +27,44 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The health status code of the endpoint - """ + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The health status code of the endpoint.""" UNKNOWN = "unknown" HEALTHY = "healthy" UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -74,24 +74,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -100,13 +100,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -115,25 +115,25 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operations monitoring level. - """ + +class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operations monitoring level.""" NONE = "None" ERROR = "Error" INFORMATION = "Information" ERROR_INFORMATION = "Error, Information" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -141,9 +141,9 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py index 234c3d982d55..66d946d3c062 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -24,25 +32,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -60,31 +63,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2018_04_01.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -92,7 +90,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -100,24 +98,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,35 +132,30 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -177,7 +165,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -202,34 +190,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -240,7 +224,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -249,25 +233,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -286,32 +265,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2018_04_01.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -319,7 +293,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -335,13 +309,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -349,7 +323,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -364,47 +338,47 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2018_04_01.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. :vartype endpoint_id: str - :ivar health_status: The health status code of the endpoint. Possible values include: - "unknown", "healthy", "unhealthy", "dead". + :ivar health_status: The health status code of the endpoint. Known values are: "unknown", + "healthy", "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthStatus """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, **kwargs ): """ :keyword endpoint_id: Id of the endpoint. :paramtype endpoint_id: str - :keyword health_status: The health status code of the endpoint. Possible values include: - "unknown", "healthy", "unhealthy", "dead". + :keyword health_status: The health status code of the endpoint. Known values are: "unknown", + "healthy", "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthStatus """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -416,30 +390,25 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -455,33 +424,29 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -499,31 +464,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, str] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -531,7 +491,7 @@ def __init__( self.etag = None -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -543,37 +503,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -587,36 +542,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -624,48 +575,42 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, } - def __init__( - self, - *, - export_blob_container_uri: str, - exclude_keys: bool, - **kwargs - ): + def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **kwargs): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -673,39 +618,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -716,21 +661,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -738,7 +683,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -755,13 +700,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -785,95 +730,85 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, } - def __init__( - self, - *, - input_blob_container_uri: str, - output_blob_container_uri: str, - **kwargs - ): + def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **kwargs): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -886,41 +821,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -941,68 +870,68 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2018_04_01.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2018_04_01.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1014,71 +943,60 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1126,48 +1044,51 @@ class IotHubProperties(msrest.serialization.Model): TwinQueries, JobsOperations, DirectMethods. :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2018_04_01.models.OperationsMonitoringProperties - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2018_04_01.models.Capabilities """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, } _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "operations_monitoring_properties": { + "key": "operationsMonitoringProperties", + "type": "OperationsMonitoringProperties", + }, + "features": {"key": "features", "type": "str"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - operations_monitoring_properties: Optional["OperationsMonitoringProperties"] = None, - features: Optional[Union[str, "Capabilities"]] = None, + operations_monitoring_properties: Optional["_models.OperationsMonitoringProperties"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1208,11 +1129,11 @@ def __init__( TwinQueries, JobsOperations, DirectMethods. :paramtype operations_monitoring_properties: ~azure.mgmt.iothub.v2018_04_01.models.OperationsMonitoringProperties - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2018_04_01.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules self.provisioning_state = None @@ -1229,7 +1150,7 @@ def __init__( self.features = features -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1237,36 +1158,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1278,30 +1195,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1310,44 +1222,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2018_04_01.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2018_04_01.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1359,131 +1265,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2018_04_01.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2018_04_01.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1494,12 +1382,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2018_04_01.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2018_04_01.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1510,34 +1398,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1548,7 +1432,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1560,30 +1444,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -1591,24 +1470,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1624,13 +1498,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1653,13 +1527,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -1669,29 +1543,23 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1703,30 +1571,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2018_04_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1740,61 +1603,52 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1806,27 +1660,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationsMonitoringProperties(msrest.serialization.Model): +class OperationsMonitoringProperties(_serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. :ivar events: Dictionary of :code:``. @@ -1835,101 +1685,92 @@ class OperationsMonitoringProperties(msrest.serialization.Model): """ _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, + "events": {"key": "events", "type": "{str}"}, } - def __init__( - self, - *, - events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, - **kwargs - ): + def __init__(self, *, events: Optional[Dict[str, Union[str, "_models.OperationMonitoringLevel"]]] = None, **kwargs): """ :keyword events: Dictionary of :code:``. :paramtype events: dict[str, str or ~azure.mgmt.iothub.v2018_04_01.models.OperationMonitoringLevel] """ - super(OperationsMonitoringProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.events = events -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -1939,29 +1780,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -1971,15 +1806,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -1988,79 +1823,79 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2068,7 +1903,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2089,19 +1924,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -2121,24 +1956,24 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2018_04_01.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the event hub endpoint. + :ivar connection_string: The connection string of the event hub endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -2147,15 +1982,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2168,26 +2003,26 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the event hub endpoint. + :keyword connection_string: The connection string of the event hub endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -2199,9 +2034,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -2220,13 +2055,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -2246,17 +2081,17 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, **kwargs ): """ @@ -2275,24 +2110,24 @@ def __init__( specified in the 'routes' section get routed to the built-in eventhub endpoint. :paramtype fallback_route: ~azure.mgmt.iothub.v2018_04_01.models.FallbackRouteProperties """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :ivar connection_string: The connection string of the service bus queue endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -2301,15 +2136,15 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2322,38 +2157,38 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :keyword connection_string: The connection string of the service bus queue endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :ivar connection_string: The connection string of the service bus topic endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual topic name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -2362,15 +2197,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2383,43 +2218,43 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :keyword connection_string: The connection string of the service bus topic endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. The name need not be the same as the + actual topic name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the storage account. + :ivar connection_string: The connection string of the storage account. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2437,23 +2272,23 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -2471,18 +2306,18 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the storage account. + :keyword connection_string: The connection string of the storage account. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, operationsMonitoringEvents, fileNotifications, $default. + Endpoint names must be unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2498,7 +2333,7 @@ def __init__( 'avro' and 'avroDeflate'. Default value is 'avro'. :paramtype encoding: str """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id @@ -2510,136 +2345,128 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired_properties: Twin desired properties. - :vartype desired_properties: any + :vartype desired_properties: JSON :ivar reported_properties: Twin desired properties. - :vartype reported_properties: any + :vartype reported_properties: JSON """ _attribute_map = { - 'desired_properties': {'key': 'desiredProperties', 'type': 'object'}, - 'reported_properties': {'key': 'reportedProperties', 'type': 'object'}, + "desired_properties": {"key": "desiredProperties", "type": "object"}, + "reported_properties": {"key": "reportedProperties", "type": "object"}, } def __init__( - self, - *, - desired_properties: Optional[Any] = None, - reported_properties: Optional[Any] = None, - **kwargs + self, *, desired_properties: Optional[JSON] = None, reported_properties: Optional[JSON] = None, **kwargs ): """ :keyword desired_properties: Twin desired properties. - :paramtype desired_properties: any + :paramtype desired_properties: JSON :keyword reported_properties: Twin desired properties. - :paramtype reported_properties: any + :paramtype reported_properties: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired_properties = desired_properties self.reported_properties = reported_properties -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2018_04_01.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2018_04_01.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2652,31 +2479,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -2685,23 +2507,23 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } def __init__( @@ -2717,49 +2539,44 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage @@ -2768,35 +2585,35 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -2804,102 +2621,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2018_04_01.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2018_04_01.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2018_04_01.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -2907,25 +2718,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2018_04_01.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -2943,23 +2749,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -2976,7 +2782,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2018_04_01.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -2985,7 +2791,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -2997,24 +2803,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/__init__.py index 68f403afba22..64c35ba588b5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/__init__.py @@ -11,9 +11,15 @@ from ._resource_provider_common_operations import ResourceProviderCommonOperations from ._certificates_operations import CertificatesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py index e16b781d11e8..8290efc651ad 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_04_01.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2018_04_01.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2018_04_01.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py index 0a8da21cedb0..0712139c6799 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,967 +6,839 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2018-04-01" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2018-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_04_01.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -973,76 +846,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -1051,15 +940,18 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1071,114 +963,222 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2018_04_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1190,111 +1190,186 @@ def begin_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2018_04_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1304,90 +1379,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription - or ~azure.mgmt.iothub.v2018_04_01.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1401,7 +1482,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1411,56 +1494,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1474,7 +1555,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1484,49 +1567,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1534,65 +1618,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1606,7 +1691,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,68 +1703,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1691,7 +1776,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1701,57 +1788,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1759,61 +1848,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1821,61 +1913,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1886,60 +1981,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1953,7 +2045,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1963,55 +2057,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2019,65 +2113,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2091,7 +2186,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2101,61 +2198,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2169,7 +2264,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2179,50 +2276,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2018_04_01.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2018_04_01.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2230,61 +2381,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(input, 'TestAllRoutesInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2292,61 +2514,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(input, 'TestRouteInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2354,67 +2647,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2428,7 +2722,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2438,55 +2734,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2494,24 +2792,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2520,39 +2819,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2018_04_01.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2018_04_01.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2560,24 +2945,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2586,39 +2972,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2018_04_01.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2018_04_01.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2626,12 +3098,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py index 52cd6c72b4e2..ae4ea0042988 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_04_01.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py index 6ba5aff172f3..6efc7e46bf61 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-04-01" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2018_04_01.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py index cd5c63745cf2..13d7b2f3b92e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-03-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-03-22") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-03-22" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py index 951b3ca1b38b..cdbf47476858 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py @@ -7,21 +7,28 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -35,12 +42,15 @@ class IotHubClient: :vartype certificates: azure.mgmt.iothub.v2019_03_22.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2019_03_22.operations.IotHubOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-03-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -61,16 +71,13 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,7 +86,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_metadata.json index fc5e51cb66cb..b7007f1a01f5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py index 3bae35d63381..94f8c4a5dc5f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-03-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-03-22") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-03-22" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py index a782c8bcf8e1..74ade549d742 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py @@ -7,21 +7,28 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -36,12 +43,15 @@ class IotHubClient: :vartype certificates: azure.mgmt.iothub.v2019_03_22.aio.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2019_03_22.aio.operations.IotHubOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-03-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -62,16 +72,13 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -80,7 +87,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/__init__.py index b95fca917d02..6d99efb7caff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/__init__.py @@ -12,10 +12,16 @@ from ._certificates_operations import CertificatesOperations from ._iot_hub_operations import IotHubOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py index 2fb6cf7150c3..a009bf62e36c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2019_03_22.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2019_03_22.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py index d3da730ab3cd..baaa902fefc4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_operations import build_manual_failover_request_initial -T = TypeVar('T') +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubOperations: - """IotHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.aio.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _manual_failover_initial( + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -100,14 +200,18 @@ async def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -118,43 +222,48 @@ async def begin_manual_failover( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._manual_failover_initial( + raw_result = await self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py index 76472d2e0237..2484153534a3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +125,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +309,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +334,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2019_03_22.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +473,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2019_03_22.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +664,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription or - ~azure.mgmt.iothub.v2019_03_22.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +769,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +781,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +845,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +857,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +910,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +983,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +995,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1068,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1080,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,61 +1140,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,61 +1205,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1008,60 +1273,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1075,7 +1340,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1085,55 +1352,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1141,65 +1410,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1213,7 +1483,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1223,61 +1495,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1291,7 +1562,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,50 +1574,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2019_03_22.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2019_03_22.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] - _json = self._serialize.body(operation_inputs, 'OperationInputs') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1352,61 +1679,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] - _json = self._serialize.body(input, 'TestAllRoutesInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1414,61 +1812,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] - _json = self._serialize.body(input, 'TestRouteInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1476,67 +1945,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1550,7 +2020,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1560,55 +2032,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,24 +2090,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1642,39 +2117,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1682,24 +2243,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1708,39 +2270,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1748,12 +2396,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py index f28df237f22e..6b02054cdc9e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py index 01f77bcf4b4a..5940e845f9fa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/__init__.py index db0d9c0ada4a..29447a7dfd3d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/__init__.py @@ -73,105 +73,107 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - Capabilities, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FailoverInput', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubLocationDescription', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'Capabilities', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubReplicaRoleType', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'RouteErrorSeverity', - 'RoutingSource', - 'RoutingStorageContainerPropertiesEncoding', - 'TestResultStatus', + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "Capabilities", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py index 19ff62f5aabe..e59777721cda 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,16 +27,19 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Health statuses have following meanings. The 'healthy' status shows that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an @@ -47,7 +48,7 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or - rejected from this endpoint + rejected from this endpoint. """ UNKNOWN = "unknown" @@ -55,14 +56,15 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired region and also the region where the IoT hub can failover to. @@ -71,17 +73,17 @@ class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -91,24 +93,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -117,13 +119,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -132,16 +134,16 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -149,7 +151,8 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -158,9 +161,9 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEn AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py index 3b9699b9de18..b5f128f79f9d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -24,25 +32,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -60,31 +63,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2019_03_22.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -92,7 +90,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -100,24 +98,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,35 +132,30 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -177,7 +165,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -202,34 +190,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -240,7 +224,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -249,25 +233,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -286,32 +265,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2019_03_22.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -319,7 +293,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -335,13 +309,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -349,7 +323,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -364,13 +338,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2019_03_22.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. @@ -383,21 +357,21 @@ class EndpointHealthData(msrest.serialization.Model): accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered - to or rejected from this endpoint. Possible values include: "unknown", "healthy", "unhealthy", + to or rejected from this endpoint. Known values are: "unknown", "healthy", "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthStatus """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, **kwargs ): """ @@ -411,16 +385,16 @@ def __init__( is not accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have - been delivered to or rejected from this endpoint. Possible values include: "unknown", - "healthy", "unhealthy", "dead". + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthStatus """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -432,30 +406,25 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -471,33 +440,29 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -515,31 +480,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, str] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -547,7 +507,7 @@ def __init__( self.etag = None -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -559,37 +519,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -603,36 +558,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -640,79 +591,68 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, } - def __init__( - self, - *, - export_blob_container_uri: str, - exclude_keys: bool, - **kwargs - ): + def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **kwargs): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys -class FailoverInput(msrest.serialization.Model): +class FailoverInput(_serialization.Model): """Use to provide failover region when requesting manual Failover for a hub. All required parameters must be populated in order to send to Azure. - :ivar failover_region: Required. Region the hub will be failed over to. + :ivar failover_region: Region the hub will be failed over to. Required. :vartype failover_region: str """ _validation = { - 'failover_region': {'required': True}, + "failover_region": {"required": True}, } _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, + "failover_region": {"key": "failoverRegion", "type": "str"}, } - def __init__( - self, - *, - failover_region: str, - **kwargs - ): + def __init__(self, *, failover_region: str, **kwargs): """ - :keyword failover_region: Required. Region the hub will be failed over to. + :keyword failover_region: Region the hub will be failed over to. Required. :paramtype failover_region: str """ - super(FailoverInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_region = failover_region -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -720,39 +660,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -763,21 +703,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -785,7 +725,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -802,13 +742,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -832,95 +772,85 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, } - def __init__( - self, - *, - input_blob_container_uri: str, - output_blob_container_uri: str, - **kwargs - ): + def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **kwargs): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -933,41 +863,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -988,68 +912,68 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2019_03_22.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2019_03_22.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1061,51 +985,46 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubLocationDescription(msrest.serialization.Model): +class IotHubLocationDescription(_serialization.Model): """Public representation of one of the locations where a resource is provisioned. :ivar location: The name of the Azure region. :vartype location: str :ivar role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery - (DR) paired region and also the region where the IoT hub can failover to. Possible values - include: "primary", "secondary". + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". :vartype role: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubReplicaRoleType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, **kwargs ): """ @@ -1113,57 +1032,51 @@ def __init__( :paramtype location: str :keyword role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster - recovery (DR) paired region and also the region where the IoT hub can failover to. Possible - values include: "primary", "secondary". + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". :paramtype role: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubReplicaRoleType """ - super(IotHubLocationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.role = role -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1205,50 +1118,50 @@ class IotHubProperties(msrest.serialization.Model): :vartype cloud_to_device: ~azure.mgmt.iothub.v2019_03_22.models.CloudToDeviceProperties :ivar comments: IoT hub comments. :vartype comments: str - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2019_03_22.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubLocationDescription] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, - 'locations': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, } _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'features': {'key': 'features', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "features": {"key": "features", "type": "str"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - features: Optional[Union[str, "Capabilities"]] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1283,11 +1196,11 @@ def __init__( :paramtype cloud_to_device: ~azure.mgmt.iothub.v2019_03_22.models.CloudToDeviceProperties :keyword comments: IoT hub comments. :paramtype comments: str - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2019_03_22.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules self.provisioning_state = None @@ -1304,7 +1217,7 @@ def __init__( self.locations = None -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1312,36 +1225,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1353,30 +1262,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1385,44 +1289,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2019_03_22.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2019_03_22.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1434,131 +1332,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2019_03_22.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2019_03_22.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1569,12 +1449,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2019_03_22.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2019_03_22.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1585,34 +1465,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1623,7 +1499,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1635,30 +1511,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -1666,24 +1537,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1699,13 +1565,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1728,13 +1594,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -1744,29 +1610,23 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1778,30 +1638,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2019_03_22.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1817,64 +1672,55 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1886,103 +1732,95 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -1992,29 +1830,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -2024,15 +1856,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -2041,79 +1873,79 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2121,7 +1953,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2142,19 +1974,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -2174,24 +2006,24 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2019_03_22.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the event hub endpoint. + :ivar connection_string: The connection string of the event hub endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -2200,15 +2032,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2221,26 +2053,26 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the event hub endpoint. + :keyword connection_string: The connection string of the event hub endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -2252,9 +2084,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -2273,13 +2105,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -2299,17 +2131,17 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, **kwargs ): """ @@ -2328,24 +2160,23 @@ def __init__( specified in the 'routes' section get routed to the built-in eventhub endpoint. :paramtype fallback_route: ~azure.mgmt.iothub.v2019_03_22.models.FallbackRouteProperties """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :ivar connection_string: The connection string of the service bus queue endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -2354,15 +2185,15 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2375,38 +2206,37 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :keyword connection_string: The connection string of the service bus queue endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :ivar connection_string: The connection string of the service bus topic endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -2415,15 +2245,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2436,43 +2266,43 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :keyword connection_string: The connection string of the service bus topic endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the storage account. + :ivar connection_string: The connection string of the storage account. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2485,30 +2315,30 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :vartype max_chunk_size_in_bytes: int :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :vartype encoding: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingStorageContainerPropertiesEncoding """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -2522,22 +2352,22 @@ def __init__( file_name_format: Optional[str] = None, batch_frequency_in_seconds: Optional[int] = None, max_chunk_size_in_bytes: Optional[int] = None, - encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): """ - :keyword connection_string: Required. The connection string of the storage account. + :keyword connection_string: The connection string of the storage account. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2550,12 +2380,12 @@ def __init__( Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :paramtype max_chunk_size_in_bytes: int :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :paramtype encoding: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingStorageContainerPropertiesEncoding """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id @@ -2567,136 +2397,126 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired: Twin desired properties. - :vartype desired: any + :vartype desired: JSON :ivar reported: Twin desired properties. - :vartype reported: any + :vartype reported: JSON """ _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, } - def __init__( - self, - *, - desired: Optional[Any] = None, - reported: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): """ :keyword desired: Twin desired properties. - :paramtype desired: any + :paramtype desired: JSON :keyword reported: Twin desired properties. - :paramtype reported: any + :paramtype reported: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired = desired self.reported = reported -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2019_03_22.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2019_03_22.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2709,31 +2529,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -2742,23 +2557,23 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } def __init__( @@ -2774,49 +2589,44 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage @@ -2825,35 +2635,35 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -2861,102 +2671,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2019_03_22.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2019_03_22.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2019_03_22.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -2964,25 +2768,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2019_03_22.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -3000,23 +2799,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -3033,7 +2832,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2019_03_22.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -3042,7 +2841,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3054,24 +2853,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/__init__.py index b95fca917d02..6d99efb7caff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/__init__.py @@ -12,10 +12,16 @@ from ._certificates_operations import CertificatesOperations from ._iot_hub_operations import IotHubOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py index 4dcff655b801..128776b7b678 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2019_03_22.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2019_03_22.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py index 5b443b3b4450..f283af4b8280 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,141 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_manual_failover_request_initial( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class IotHubOperations(object): - """IotHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _manual_failover_initial( + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") - request = build_manual_failover_request_initial( + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> LROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -147,14 +237,18 @@ def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -165,43 +259,48 @@ def begin_manual_failover( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._manual_failover_initial( + raw_result = self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py index 586341a29d20..c6c4b48b845d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,967 +6,839 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2019-03-22" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-03-22" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -973,76 +846,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -1051,15 +940,18 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1071,114 +963,222 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2019_03_22.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1190,111 +1190,186 @@ def begin_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2019_03_22.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1304,90 +1379,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription - or ~azure.mgmt.iothub.v2019_03_22.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1401,7 +1482,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1411,56 +1494,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1474,7 +1555,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1484,49 +1567,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1534,65 +1618,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1606,7 +1691,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,68 +1703,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1691,7 +1776,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1701,57 +1788,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1759,61 +1848,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1821,61 +1913,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1886,60 +1981,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1953,7 +2045,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1963,55 +2057,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2019,65 +2113,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2091,7 +2186,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2101,61 +2198,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2169,7 +2264,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2179,50 +2276,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2019_03_22.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2019_03_22.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2230,61 +2381,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(input, 'TestAllRoutesInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2292,61 +2514,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(input, 'TestRouteInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2354,67 +2647,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2428,7 +2722,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2438,55 +2734,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2494,24 +2792,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2520,39 +2819,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2560,24 +2945,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2586,39 +2972,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2626,12 +3098,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py index 1e4a39cc4c0a..5d83b6282026 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py index 38666fafa756..82bc95b509df 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-03-22" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_03_22.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_03_22.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py index 4d73b23ea30a..3210ab329adf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-07-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-07-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py index 9cdd0e184440..6d02c3866063 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py @@ -7,21 +7,28 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -36,12 +43,15 @@ class IotHubClient: :vartype certificates: azure.mgmt.iothub.v2019_07_01_preview.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2019_07_01_preview.operations.IotHubOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -62,16 +72,13 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -80,7 +87,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_metadata.json index 6ca10e975b29..7a57abcec424 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py index 03687e3c970b..eb680cb8cd67 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-07-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-07-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py index 554abd2a2516..c4740f271b45 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py @@ -7,21 +7,28 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -37,12 +44,15 @@ class IotHubClient: azure.mgmt.iothub.v2019_07_01_preview.aio.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2019_07_01_preview.aio.operations.IotHubOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -63,16 +73,13 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -81,7 +88,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/__init__.py index b95fca917d02..6d99efb7caff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/__init__.py @@ -12,10 +12,16 @@ from ._certificates_operations import CertificatesOperations from ._iot_hub_operations import IotHubOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py index 4f0c10b2d5fe..0f2b1ff09b70 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,87 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,55 +254,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: - ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -219,64 +330,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -287,55 +400,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -343,15 +458,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -360,54 +547,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -415,12 +621,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py index 057b2134e253..1e3871c13a3b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,201 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_operations import build_manual_failover_request_initial -T = TypeVar('T') +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubOperations: - """IotHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.aio.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _manual_failover_initial( + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manual Failover Fail over. + + Perform manual fail over of given hub. + + :param iot_hub_name: IotHub to fail over. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be a azure DR pair. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manual Failover Fail over. + + Perform manual fail over of given hub. + :param iot_hub_name: IotHub to fail over. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be a azure DR pair. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Manual Failover Fail over. Perform manual fail over of given hub. - :param iot_hub_name: IotHub to fail over. + :param iot_hub_name: IotHub to fail over. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param failover_input: Region to failover to. Must be a azure DR pair. - :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput + :param failover_input: Region to failover to. Must be a azure DR pair. Is either a model type + or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -115,43 +211,48 @@ async def begin_manual_failover( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._manual_failover_initial( + raw_result = await self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py index ef121d2789ad..5ae07d83f3e4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +125,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +309,20 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription or + IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +335,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2019_07_01_preview.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +474,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2019_07_01_preview.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +665,99 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription - or ~azure.mgmt.iothub.v2019_07_01_preview.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +771,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +783,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +847,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +859,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +912,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +985,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +997,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1070,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1082,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,61 +1142,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,61 +1207,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1008,60 +1275,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1075,7 +1342,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1085,55 +1354,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1141,65 +1412,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1213,7 +1485,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1223,61 +1497,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1291,7 +1564,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,50 +1576,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1352,61 +1681,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] - _json = self._serialize.body(input, 'TestAllRoutesInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1414,61 +1814,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. - _json = self._serialize.body(input, 'TestRouteInput') + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1476,67 +1947,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1550,7 +2022,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1560,55 +2034,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,24 +2092,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1642,40 +2119,126 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1683,24 +2246,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1709,40 +2273,126 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1750,12 +2400,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py index 8e1fd34f8682..6ee594ef433d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py index 083b5a669602..6dd380cb664f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/__init__.py index 837cba04f503..f94e3e6d6866 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/__init__.py @@ -75,107 +75,109 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - Capabilities, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'EnrichmentProperties', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FailoverInput', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubLocationDescription', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubPropertiesDeviceStreams', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'Capabilities', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubReplicaRoleType', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'RouteErrorSeverity', - 'RoutingSource', - 'RoutingStorageContainerPropertiesEncoding', - 'TestResultStatus', + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubPropertiesDeviceStreams", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "Capabilities", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py index 618c9a456b12..35977cfabec3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,16 +27,19 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Health statuses have following meanings. The 'healthy' status shows that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an @@ -47,7 +48,7 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or - rejected from this endpoint + rejected from this endpoint. """ UNKNOWN = "unknown" @@ -55,31 +56,31 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Specific Role assigned to this location - """ + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specific Role assigned to this location.""" PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -89,24 +90,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -115,13 +116,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -130,16 +131,16 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -148,7 +149,8 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" DIGITAL_TWIN_CHANGE_EVENTS = "DigitalTwinChangeEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -157,9 +159,9 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEn AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py index c37f85003c33..62019aca4861 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -24,25 +32,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -60,31 +63,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -92,7 +90,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -100,24 +98,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,35 +132,30 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -177,7 +165,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -202,34 +190,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -240,7 +224,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -249,25 +233,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -287,33 +266,28 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -321,7 +295,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -337,13 +311,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -351,7 +325,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -366,13 +340,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2019_07_01_preview.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. @@ -385,22 +359,22 @@ class EndpointHealthData(msrest.serialization.Model): accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered - to or rejected from this endpoint. Possible values include: "unknown", "healthy", "unhealthy", + to or rejected from this endpoint. Known values are: "unknown", "healthy", "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthStatus """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, **kwargs ): """ @@ -414,17 +388,17 @@ def __init__( is not accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have - been delivered to or rejected from this endpoint. Possible values include: "unknown", - "healthy", "unhealthy", "dead". + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthStatus """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -436,79 +410,67 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EnrichmentProperties(msrest.serialization.Model): +class EnrichmentProperties(_serialization.Model): """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. All required parameters must be populated in order to send to Azure. - :ivar key: Required. The key or name for the enrichment property. + :ivar key: The key or name for the enrichment property. Required. :vartype key: str - :ivar value: Required. The value for the enrichment property. + :ivar value: The value for the enrichment property. Required. :vartype value: str - :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. :vartype endpoint_names: list[str] """ _validation = { - 'key': {'required': True}, - 'value': {'required': True}, - 'endpoint_names': {'required': True, 'min_items': 1}, + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, } _attribute_map = { - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, } - def __init__( - self, - *, - key: str, - value: str, - endpoint_names: List[str], - **kwargs - ): + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs): """ - :keyword key: Required. The key or name for the enrichment property. + :keyword key: The key or name for the enrichment property. Required. :paramtype key: str - :keyword value: Required. The value for the enrichment property. + :keyword value: The value for the enrichment property. Required. :paramtype value: str - :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. :paramtype endpoint_names: list[str] """ - super(EnrichmentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.value = value self.endpoint_names = endpoint_names -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -524,33 +486,29 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -568,31 +526,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, str] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -600,7 +553,7 @@ def __init__( self.etag = None -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -612,37 +565,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -656,36 +604,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -693,79 +637,68 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, } - def __init__( - self, - *, - export_blob_container_uri: str, - exclude_keys: bool, - **kwargs - ): + def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **kwargs): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys -class FailoverInput(msrest.serialization.Model): +class FailoverInput(_serialization.Model): """Use to provide failover region when requesting manual Failover for a hub. All required parameters must be populated in order to send to Azure. - :ivar failover_region: Required. Region the hub will be failed over to. + :ivar failover_region: Region the hub will be failed over to. Required. :vartype failover_region: str """ _validation = { - 'failover_region': {'required': True}, + "failover_region": {"required": True}, } _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, + "failover_region": {"key": "failoverRegion", "type": "str"}, } - def __init__( - self, - *, - failover_region: str, - **kwargs - ): + def __init__(self, *, failover_region: str, **kwargs): """ - :keyword failover_region: Required. Region the hub will be failed over to. + :keyword failover_region: Region the hub will be failed over to. Required. :paramtype failover_region: str """ - super(FailoverInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_region = failover_region -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -773,39 +706,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DigitalTwinChangeEvents". :vartype source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -816,22 +749,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DigitalTwinChangeEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DigitalTwinChangeEvents". :paramtype source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -839,7 +771,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -856,13 +788,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -886,95 +818,85 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, } - def __init__( - self, - *, - input_blob_container_uri: str, - output_blob_container_uri: str, - **kwargs - ): + def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **kwargs): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -987,41 +909,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1042,68 +958,68 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1115,72 +1031,66 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubLocationDescription(msrest.serialization.Model): +class IotHubLocationDescription(_serialization.Model): """Public representation of one of the locations where a resource is provisioned. :ivar location: Azure Geo Regions. :vartype location: str - :ivar role: Specific Role assigned to this location. Possible values include: "primary", + :ivar role: Specific Role assigned to this location. Known values are: "primary" and "secondary". :vartype role: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubReplicaRoleType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, **kwargs ): """ :keyword location: Azure Geo Regions. :paramtype location: str - :keyword role: Specific Role assigned to this location. Possible values include: "primary", + :keyword role: Specific Role assigned to this location. Known values are: "primary" and "secondary". :paramtype role: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubReplicaRoleType """ - super(IotHubLocationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.role = role -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. @@ -1188,33 +1098,28 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1259,8 +1164,8 @@ class IotHubProperties(msrest.serialization.Model): :ivar device_streams: The device streams properties of iothub. :vartype device_streams: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubPropertiesDeviceStreams - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: @@ -1268,44 +1173,44 @@ class IotHubProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, - 'locations': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'device_streams': {'key': 'deviceStreams', 'type': 'IotHubPropertiesDeviceStreams'}, - 'features': {'key': 'features', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "device_streams": {"key": "deviceStreams", "type": "IotHubPropertiesDeviceStreams"}, + "features": {"key": "features", "type": "str"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - device_streams: Optional["IotHubPropertiesDeviceStreams"] = None, - features: Optional[Union[str, "Capabilities"]] = None, + device_streams: Optional["_models.IotHubPropertiesDeviceStreams"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1344,11 +1249,11 @@ def __init__( :keyword device_streams: The device streams properties of iothub. :paramtype device_streams: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubPropertiesDeviceStreams - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules self.provisioning_state = None @@ -1366,7 +1271,7 @@ def __init__( self.locations = None -class IotHubPropertiesDeviceStreams(msrest.serialization.Model): +class IotHubPropertiesDeviceStreams(_serialization.Model): """The device streams properties of iothub. :ivar streaming_endpoints: List of Device Streams Endpoints. @@ -1374,24 +1279,19 @@ class IotHubPropertiesDeviceStreams(msrest.serialization.Model): """ _attribute_map = { - 'streaming_endpoints': {'key': 'streamingEndpoints', 'type': '[str]'}, + "streaming_endpoints": {"key": "streamingEndpoints", "type": "[str]"}, } - def __init__( - self, - *, - streaming_endpoints: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, streaming_endpoints: Optional[List[str]] = None, **kwargs): """ :keyword streaming_endpoints: List of Device Streams Endpoints. :paramtype streaming_endpoints: list[str] """ - super(IotHubPropertiesDeviceStreams, self).__init__(**kwargs) + super().__init__(**kwargs) self.streaming_endpoints = streaming_endpoints -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1399,36 +1299,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1440,30 +1336,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1472,44 +1363,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1521,131 +1406,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1656,12 +1523,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1672,34 +1539,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1710,7 +1573,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1722,30 +1585,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -1753,24 +1611,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1786,13 +1639,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1815,13 +1668,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -1831,29 +1684,23 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1865,30 +1712,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1904,64 +1746,55 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1973,103 +1806,95 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -2079,29 +1904,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -2111,15 +1930,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -2128,79 +1947,79 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DigitalTwinChangeEvents". :vartype source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DigitalTwinChangeEvents". :paramtype source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2208,7 +2027,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2230,19 +2049,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -2263,24 +2082,24 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the event hub endpoint. + :ivar connection_string: The connection string of the event hub endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -2289,15 +2108,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2310,26 +2129,26 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the event hub endpoint. + :keyword connection_string: The connection string of the event hub endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -2341,9 +2160,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -2362,13 +2181,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -2391,19 +2210,19 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - 'enrichments': {'key': 'enrichments', 'type': '[EnrichmentProperties]'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, - enrichments: Optional[List["EnrichmentProperties"]] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, **kwargs ): """ @@ -2427,25 +2246,24 @@ def __init__( :paramtype enrichments: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EnrichmentProperties] """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route self.enrichments = enrichments -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :ivar connection_string: The connection string of the service bus queue endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -2454,15 +2272,15 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2475,38 +2293,37 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :keyword connection_string: The connection string of the service bus queue endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :ivar connection_string: The connection string of the service bus topic endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -2515,15 +2332,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2536,43 +2353,43 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :keyword connection_string: The connection string of the service bus topic endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the storage account. + :ivar connection_string: The connection string of the storage account. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2585,30 +2402,30 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :vartype max_chunk_size_in_bytes: int :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :vartype encoding: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingStorageContainerPropertiesEncoding """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -2622,22 +2439,22 @@ def __init__( file_name_format: Optional[str] = None, batch_frequency_in_seconds: Optional[int] = None, max_chunk_size_in_bytes: Optional[int] = None, - encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): """ - :keyword connection_string: Required. The connection string of the storage account. + :keyword connection_string: The connection string of the storage account. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2650,12 +2467,12 @@ def __init__( Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :paramtype max_chunk_size_in_bytes: int :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :paramtype encoding: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingStorageContainerPropertiesEncoding """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id @@ -2667,136 +2484,126 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired: Twin desired properties. - :vartype desired: any + :vartype desired: JSON :ivar reported: Twin desired properties. - :vartype reported: any + :vartype reported: JSON """ _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, } - def __init__( - self, - *, - desired: Optional[Any] = None, - reported: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): """ :keyword desired: Twin desired properties. - :paramtype desired: any + :paramtype desired: JSON :keyword reported: Twin desired properties. - :paramtype reported: any + :paramtype reported: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired = desired self.reported = reported -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2809,31 +2616,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -2842,23 +2644,23 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } def __init__( @@ -2874,49 +2676,44 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DigitalTwinChangeEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource :ivar message: Routing message. @@ -2926,22 +2723,22 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DigitalTwinChangeEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource :keyword message: Routing message. @@ -2949,13 +2746,13 @@ def __init__( :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -2963,102 +2760,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2019_07_01_preview.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -3067,25 +2858,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -3103,23 +2889,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -3136,7 +2922,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2019_07_01_preview.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -3145,7 +2931,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3157,24 +2943,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/__init__.py index b95fca917d02..6d99efb7caff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/__init__.py @@ -12,10 +12,16 @@ from ._certificates_operations import CertificatesOperations from ._iot_hub_operations import IotHubOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py index b82824c8f721..5b92971d0e1e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,87 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,55 +486,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: - ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -471,64 +562,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -539,55 +632,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -595,15 +690,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -612,54 +779,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,12 +853,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py index 79e771d2eeed..3df6060c5eda 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,153 +6,238 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_manual_failover_request_initial( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class IotHubOperations(object): - """IotHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _manual_failover_initial( + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manual Failover Fail over. + + Perform manual fail over of given hub. + + :param iot_hub_name: IotHub to fail over. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be a azure DR pair. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manual Failover Fail over. + Perform manual fail over of given hub. + + :param iot_hub_name: IotHub to fail over. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be a azure DR pair. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> LROPoller[None]: """Manual Failover Fail over. Perform manual fail over of given hub. - :param iot_hub_name: IotHub to fail over. + :param iot_hub_name: IotHub to fail over. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param failover_input: Region to failover to. Must be a azure DR pair. - :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput + :param failover_input: Region to failover to. Must be a azure DR pair. Is either a model type + or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -162,43 +248,48 @@ def begin_manual_failover( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._manual_failover_initial( + raw_result = self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py index c5727624509f..57abe74b2d1a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,967 +6,839 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2019-07-01-preview" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -973,76 +846,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -1051,15 +940,18 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1072,114 +964,225 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription or + IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2019_07_01_preview.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1192,111 +1195,188 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2019_07_01_preview.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1306,91 +1386,98 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription - or ~azure.mgmt.iothub.v2019_07_01_preview.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1404,7 +1491,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1414,56 +1503,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1477,7 +1565,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1487,49 +1577,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1537,65 +1628,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1609,7 +1701,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1619,68 +1713,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1694,7 +1786,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1704,57 +1798,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1762,61 +1858,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1824,61 +1923,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1889,60 +1991,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1956,7 +2055,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1966,55 +2067,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2022,65 +2123,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2094,7 +2196,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2104,61 +2208,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2172,7 +2275,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2182,50 +2287,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2233,61 +2392,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. - _json = self._serialize.body(input, 'TestAllRoutesInput') + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2295,61 +2525,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore - + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. - _json = self._serialize.body(input, 'TestRouteInput') + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2357,67 +2658,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2431,7 +2733,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2441,55 +2745,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2497,24 +2803,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2523,40 +2830,126 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2564,24 +2957,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2590,40 +2984,126 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2631,12 +3111,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py index 56922073a5b9..9970e19bcbcd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -129,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py index 858af7aef515..207173c42dbd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-07-01-preview" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_07_01_preview.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py index db44b6c2402a..b0c11fd12328 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-11-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-11-04") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-11-04" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py index badc2a2e1a2a..7edce1e790d0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py @@ -7,21 +7,28 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -35,12 +42,15 @@ class IotHubClient: :vartype certificates: azure.mgmt.iothub.v2019_11_04.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2019_11_04.operations.IotHubOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-11-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -61,16 +71,13 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,7 +86,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_metadata.json index 82012676da9a..ed3f7a9ecc93 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py index e98f39e76d91..12754351a5d1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-11-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-11-04") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-11-04" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py index 49300465af52..406ba0e03306 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py @@ -7,21 +7,28 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -36,12 +43,15 @@ class IotHubClient: :vartype certificates: azure.mgmt.iothub.v2019_11_04.aio.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2019_11_04.aio.operations.IotHubOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-11-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -62,16 +72,13 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -80,7 +87,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/__init__.py index b95fca917d02..6d99efb7caff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/__init__.py @@ -12,10 +12,16 @@ from ._certificates_operations import CertificatesOperations from ._iot_hub_operations import IotHubOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py index 9a317c7b66c5..b1b68db41c9e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2019_11_04.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2019_11_04.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py index 28b9b1639fb5..cc2d3f3e1ca3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_operations import build_manual_failover_request_initial -T = TypeVar('T') +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubOperations: - """IotHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.aio.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _manual_failover_initial( + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_11_04.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -100,14 +200,18 @@ async def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2019_11_04.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_11_04.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -118,43 +222,48 @@ async def begin_manual_failover( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._manual_failover_initial( + raw_result = await self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py index 868faa55009c..934a6f6b77f9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +125,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +309,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +334,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2019_11_04.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +473,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2019_11_04.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +664,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription or - ~azure.mgmt.iothub.v2019_11_04.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +769,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +781,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +845,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +857,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +910,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +983,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +995,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1068,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1080,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,61 +1140,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,61 +1205,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1008,60 +1273,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1075,7 +1340,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1085,55 +1352,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1141,65 +1410,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1213,7 +1483,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1223,61 +1495,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1291,7 +1562,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,50 +1574,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2019_11_04.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2019_11_04.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] - _json = self._serialize.body(operation_inputs, 'OperationInputs') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1352,61 +1679,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] - _json = self._serialize.body(input, 'TestAllRoutesInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1414,61 +1812,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] - _json = self._serialize.body(input, 'TestRouteInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1476,67 +1945,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1550,7 +2020,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1560,55 +2032,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,24 +2090,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1642,39 +2117,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2019_11_04.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2019_11_04.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1682,24 +2243,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1708,39 +2270,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2019_11_04.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2019_11_04.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1748,12 +2396,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py index 37fce809b96d..5258847a950a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py index 47037cc33390..e767422d0954 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/__init__.py index e49548abc8de..b446f736ac58 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/__init__.py @@ -74,106 +74,108 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - Capabilities, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'EnrichmentProperties', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FailoverInput', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubLocationDescription', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'Capabilities', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubReplicaRoleType', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'RouteErrorSeverity', - 'RoutingSource', - 'RoutingStorageContainerPropertiesEncoding', - 'TestResultStatus', + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "Capabilities", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py index 19ff62f5aabe..e59777721cda 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,16 +27,19 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Health statuses have following meanings. The 'healthy' status shows that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an @@ -47,7 +48,7 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or - rejected from this endpoint + rejected from this endpoint. """ UNKNOWN = "unknown" @@ -55,14 +56,15 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired region and also the region where the IoT hub can failover to. @@ -71,17 +73,17 @@ class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -91,24 +93,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -117,13 +119,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -132,16 +134,16 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -149,7 +151,8 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -158,9 +161,9 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEn AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py index b243979335c6..28412710b900 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -24,25 +32,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -60,31 +63,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2019_11_04.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -92,7 +90,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -100,24 +98,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,35 +132,30 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -177,7 +165,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -202,34 +190,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -240,7 +224,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -249,25 +233,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -286,32 +265,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2019_11_04.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -319,7 +293,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -335,13 +309,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -349,7 +323,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -364,13 +338,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2019_11_04.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. @@ -383,21 +357,21 @@ class EndpointHealthData(msrest.serialization.Model): accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered - to or rejected from this endpoint. Possible values include: "unknown", "healthy", "unhealthy", + to or rejected from this endpoint. Known values are: "unknown", "healthy", "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthStatus """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, **kwargs ): """ @@ -411,16 +385,16 @@ def __init__( is not accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have - been delivered to or rejected from this endpoint. Possible values include: "unknown", - "healthy", "unhealthy", "dead". + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthStatus """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -432,79 +406,67 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EnrichmentProperties(msrest.serialization.Model): +class EnrichmentProperties(_serialization.Model): """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. All required parameters must be populated in order to send to Azure. - :ivar key: Required. The key or name for the enrichment property. + :ivar key: The key or name for the enrichment property. Required. :vartype key: str - :ivar value: Required. The value for the enrichment property. + :ivar value: The value for the enrichment property. Required. :vartype value: str - :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. :vartype endpoint_names: list[str] """ _validation = { - 'key': {'required': True}, - 'value': {'required': True}, - 'endpoint_names': {'required': True, 'min_items': 1}, + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, } _attribute_map = { - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, } - def __init__( - self, - *, - key: str, - value: str, - endpoint_names: List[str], - **kwargs - ): + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs): """ - :keyword key: Required. The key or name for the enrichment property. + :keyword key: The key or name for the enrichment property. Required. :paramtype key: str - :keyword value: Required. The value for the enrichment property. + :keyword value: The value for the enrichment property. Required. :paramtype value: str - :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. :paramtype endpoint_names: list[str] """ - super(EnrichmentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.value = value self.endpoint_names = endpoint_names -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -520,33 +482,29 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -564,31 +522,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, str] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -596,7 +549,7 @@ def __init__( self.etag = None -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -608,37 +561,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -652,36 +600,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -689,79 +633,68 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, } - def __init__( - self, - *, - export_blob_container_uri: str, - exclude_keys: bool, - **kwargs - ): + def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **kwargs): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys -class FailoverInput(msrest.serialization.Model): +class FailoverInput(_serialization.Model): """Use to provide failover region when requesting manual Failover for a hub. All required parameters must be populated in order to send to Azure. - :ivar failover_region: Required. Region the hub will be failed over to. + :ivar failover_region: Region the hub will be failed over to. Required. :vartype failover_region: str """ _validation = { - 'failover_region': {'required': True}, + "failover_region": {"required": True}, } _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, + "failover_region": {"key": "failoverRegion", "type": "str"}, } - def __init__( - self, - *, - failover_region: str, - **kwargs - ): + def __init__(self, *, failover_region: str, **kwargs): """ - :keyword failover_region: Required. Region the hub will be failed over to. + :keyword failover_region: Region the hub will be failed over to. Required. :paramtype failover_region: str """ - super(FailoverInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_region = failover_region -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -769,39 +702,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -812,21 +745,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -834,7 +767,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -851,13 +784,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -881,95 +814,85 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, } - def __init__( - self, - *, - input_blob_container_uri: str, - output_blob_container_uri: str, - **kwargs - ): + def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **kwargs): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -982,41 +905,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1037,68 +954,68 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2019_11_04.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2019_11_04.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1110,51 +1027,46 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubLocationDescription(msrest.serialization.Model): +class IotHubLocationDescription(_serialization.Model): """Public representation of one of the locations where a resource is provisioned. :ivar location: The name of the Azure region. :vartype location: str :ivar role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery - (DR) paired region and also the region where the IoT hub can failover to. Possible values - include: "primary", "secondary". + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". :vartype role: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubReplicaRoleType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, **kwargs ): """ @@ -1162,57 +1074,51 @@ def __init__( :paramtype location: str :keyword role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster - recovery (DR) paired region and also the region where the IoT hub can failover to. Possible - values include: "primary", "secondary". + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". :paramtype role: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubReplicaRoleType """ - super(IotHubLocationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.role = role -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1254,50 +1160,50 @@ class IotHubProperties(msrest.serialization.Model): :vartype cloud_to_device: ~azure.mgmt.iothub.v2019_11_04.models.CloudToDeviceProperties :ivar comments: IoT hub comments. :vartype comments: str - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2019_11_04.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubLocationDescription] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, - 'locations': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, } _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'features': {'key': 'features', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "features": {"key": "features", "type": "str"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - features: Optional[Union[str, "Capabilities"]] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1332,11 +1238,11 @@ def __init__( :paramtype cloud_to_device: ~azure.mgmt.iothub.v2019_11_04.models.CloudToDeviceProperties :keyword comments: IoT hub comments. :paramtype comments: str - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2019_11_04.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules self.provisioning_state = None @@ -1353,7 +1259,7 @@ def __init__( self.locations = None -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1361,36 +1267,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1402,30 +1304,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1434,44 +1331,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2019_11_04.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2019_11_04.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1483,131 +1374,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2019_11_04.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2019_11_04.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1618,12 +1491,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2019_11_04.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2019_11_04.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1634,34 +1507,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1672,7 +1541,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1684,30 +1553,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -1715,24 +1579,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1748,13 +1607,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1777,13 +1636,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -1793,29 +1652,23 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1827,30 +1680,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2019_11_04.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1866,64 +1714,55 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1935,103 +1774,95 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -2041,29 +1872,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -2073,15 +1898,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -2090,79 +1915,79 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2170,7 +1995,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2191,19 +2016,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -2223,24 +2048,24 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2019_11_04.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the event hub endpoint. + :ivar connection_string: The connection string of the event hub endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -2249,15 +2074,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2270,26 +2095,26 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the event hub endpoint. + :keyword connection_string: The connection string of the event hub endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -2301,9 +2126,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -2322,13 +2147,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -2351,19 +2176,19 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - 'enrichments': {'key': 'enrichments', 'type': '[EnrichmentProperties]'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, - enrichments: Optional[List["EnrichmentProperties"]] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, **kwargs ): """ @@ -2386,25 +2211,24 @@ def __init__( https://aka.ms/telemetryoneventgrid. :paramtype enrichments: list[~azure.mgmt.iothub.v2019_11_04.models.EnrichmentProperties] """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route self.enrichments = enrichments -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :ivar connection_string: The connection string of the service bus queue endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -2413,15 +2237,15 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2434,38 +2258,37 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :keyword connection_string: The connection string of the service bus queue endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :ivar connection_string: The connection string of the service bus topic endpoint. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -2474,15 +2297,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( @@ -2495,43 +2318,43 @@ def __init__( **kwargs ): """ - :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :keyword connection_string: The connection string of the service bus topic endpoint. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. - :ivar connection_string: Required. The connection string of the storage account. + :ivar connection_string: The connection string of the storage account. Required. :vartype connection_string: str - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2544,30 +2367,30 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :vartype max_chunk_size_in_bytes: int :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :vartype encoding: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingStorageContainerPropertiesEncoding """ _validation = { - 'connection_string': {'required': True}, - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "connection_string": {"required": True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -2581,22 +2404,22 @@ def __init__( file_name_format: Optional[str] = None, batch_frequency_in_seconds: Optional[int] = None, max_chunk_size_in_bytes: Optional[int] = None, - encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): """ - :keyword connection_string: Required. The connection string of the storage account. + :keyword connection_string: The connection string of the storage account. Required. :paramtype connection_string: str - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2609,12 +2432,12 @@ def __init__( Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :paramtype max_chunk_size_in_bytes: int :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :paramtype encoding: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingStorageContainerPropertiesEncoding """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_string = connection_string self.name = name self.subscription_id = subscription_id @@ -2626,136 +2449,126 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired: Twin desired properties. - :vartype desired: any + :vartype desired: JSON :ivar reported: Twin desired properties. - :vartype reported: any + :vartype reported: JSON """ _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, } - def __init__( - self, - *, - desired: Optional[Any] = None, - reported: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): """ :keyword desired: Twin desired properties. - :paramtype desired: any + :paramtype desired: JSON :keyword reported: Twin desired properties. - :paramtype reported: any + :paramtype reported: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired = desired self.reported = reported -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2019_11_04.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2019_11_04.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2768,31 +2581,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -2801,23 +2609,23 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } def __init__( @@ -2833,49 +2641,44 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage @@ -2884,35 +2687,35 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -2920,102 +2723,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2019_11_04.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2019_11_04.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2019_11_04.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -3023,25 +2820,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2019_11_04.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -3059,23 +2851,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -3092,7 +2884,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2019_11_04.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -3101,7 +2893,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3113,24 +2905,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/__init__.py index b95fca917d02..6d99efb7caff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/__init__.py @@ -12,10 +12,16 @@ from ._certificates_operations import CertificatesOperations from ._iot_hub_operations import IotHubOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py index 2871159c0bb3..14e12d9df01f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2019_11_04.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2019_11_04.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py index 61395d0c12e6..bd533fe6b90b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,141 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_manual_failover_request_initial( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class IotHubOperations(object): - """IotHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _manual_failover_initial( + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") - request = build_manual_failover_request_initial( + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_11_04.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> LROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -147,14 +237,18 @@ def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2019_11_04.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2019_11_04.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -165,43 +259,48 @@ def begin_manual_failover( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._manual_failover_initial( + raw_result = self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py index 8891bb2c035c..bb3cef3a45d8 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,967 +6,839 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2019-11-04" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2019-11-04" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -973,76 +846,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -1051,15 +940,18 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1071,114 +963,222 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2019_11_04.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1190,111 +1190,186 @@ def begin_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2019_11_04.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1304,90 +1379,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription - or ~azure.mgmt.iothub.v2019_11_04.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1401,7 +1482,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1411,56 +1494,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1474,7 +1555,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1484,49 +1567,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1534,65 +1618,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1606,7 +1691,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,68 +1703,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1691,7 +1776,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1701,57 +1788,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1759,61 +1848,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1821,61 +1913,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1886,60 +1981,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1953,7 +2045,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1963,55 +2057,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2019,65 +2113,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2091,7 +2186,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2101,61 +2198,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2169,7 +2264,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2179,50 +2276,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2019_11_04.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2019_11_04.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2230,61 +2381,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(input, 'TestAllRoutesInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2292,61 +2514,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(input, 'TestRouteInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2354,67 +2647,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2428,7 +2722,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2438,55 +2734,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2494,24 +2792,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2520,39 +2819,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2019_11_04.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2019_11_04.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2560,24 +2945,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2586,39 +2972,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2019_11_04.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2019_11_04.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2626,12 +3098,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py index c2d3f2296a2a..6688c05a2677 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py index 3492dcfa293d..d5d6c0a37915 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2019-11-04" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2019_11_04.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2019_11_04.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py index ef82a2d7b619..c2db94f3e1e6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2020-03-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-03-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py index 729a6be2075b..f36dfb943cc4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -41,12 +50,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2020_03_01.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -67,18 +79,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -87,7 +100,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_metadata.json index 7263b5339a8a..ffc7d283c8e9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py index 7a90522e2bd9..6e3735f3b830 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2020-03-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-03-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py index e7d55bb480c2..f08b210a42af 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -42,12 +51,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2020_03_01.aio.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -68,18 +80,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +101,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py index d486ba04638a..fac267cb2dce 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2020_03_01.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2020_03_01.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py index 24c42a56e959..849bb8d96b70 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_operations import build_manual_failover_request_initial -T = TypeVar('T') +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubOperations: - """IotHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.aio.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _manual_failover_initial( + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2020_03_01.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -100,14 +200,18 @@ async def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2020_03_01.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2020_03_01.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -118,43 +222,48 @@ async def begin_manual_failover( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._manual_failover_initial( + raw_result = await self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py index ae18200a4a3e..b052c602e70c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +125,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +309,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +334,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2020_03_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +473,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2020_03_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +664,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription or - ~azure.mgmt.iothub.v2020_03_01.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +769,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +781,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +845,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +857,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +910,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +983,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +995,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1068,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1080,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,61 +1140,64 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async async def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,61 +1205,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1008,60 +1273,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1075,7 +1340,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1085,55 +1352,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1141,65 +1410,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1213,7 +1483,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1223,61 +1495,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1291,7 +1562,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,50 +1574,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2020_03_01.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2020_03_01.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] - _json = self._serialize.body(operation_inputs, 'OperationInputs') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1352,61 +1679,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] - _json = self._serialize.body(input, 'TestAllRoutesInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1414,61 +1812,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] - _json = self._serialize.body(input, 'TestRouteInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1476,67 +1945,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1550,7 +2020,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1560,55 +2032,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,24 +2090,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1642,39 +2117,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2020_03_01.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2020_03_01.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1682,24 +2243,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1708,39 +2270,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2020_03_01.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2020_03_01.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1748,12 +2396,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py index 7e6d9a095008..a975ad5f1678 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py index 6301e9371f09..09e9f6bc0ba3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.aio.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,57 +105,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,89 +166,109 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -243,114 +281,201 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -364,44 +489,48 @@ async def begin_delete( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py index 87ecc58767bc..73023035fc14 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.aio.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +96,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,12 +157,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py index b98fdb828dd9..e8d579095db4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/__init__.py index 154f2039f5a6..52b78aeb740e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/__init__.py @@ -81,119 +81,121 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - AuthenticationType, - Capabilities, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - PrivateLinkServiceConnectionStatus, - PublicNetworkAccess, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import AuthenticationType +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_hub_client_enums import PublicNetworkAccess +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'EnrichmentProperties', - 'ErrorDetails', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FailoverInput', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'GroupIdInformation', - 'GroupIdInformationProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubLocationDescription', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionProperties', - 'PrivateLinkResources', - 'PrivateLinkServiceConnectionState', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'AuthenticationType', - 'Capabilities', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubReplicaRoleType', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'PrivateLinkServiceConnectionStatus', - 'PublicNetworkAccess', - 'RouteErrorSeverity', - 'RoutingSource', - 'RoutingStorageContainerPropertiesEncoding', - 'TestResultStatus', + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "GroupIdInformation", + "GroupIdInformationProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "AuthenticationType", + "Capabilities", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py index 44f1adadad66..c2b9398b02fd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,23 +27,26 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Specifies authentication type being used for connecting to the storage account. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies authentication type being used for connecting to the storage account.""" KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Health statuses have following meanings. The 'healthy' status shows that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an @@ -54,7 +55,7 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or - rejected from this endpoint + rejected from this endpoint. """ UNKNOWN = "unknown" @@ -62,14 +63,15 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired region and also the region where the IoT hub can failover to. @@ -78,17 +80,17 @@ class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -98,24 +100,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -124,13 +126,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -139,32 +141,32 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of a private endpoint connection - """ + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether requests from Public Network are allowed - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -172,7 +174,8 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -181,9 +184,9 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEn AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py index f8e30068d236..da9a4fa309a1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -24,25 +32,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -60,31 +63,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -92,7 +90,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -100,24 +98,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,35 +132,30 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -177,7 +165,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -202,34 +190,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -240,7 +224,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -249,25 +233,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -286,32 +265,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -319,7 +293,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -335,13 +309,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -349,7 +323,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -364,13 +338,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2020_03_01.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. @@ -383,21 +357,21 @@ class EndpointHealthData(msrest.serialization.Model): accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered - to or rejected from this endpoint. Possible values include: "unknown", "healthy", "unhealthy", + to or rejected from this endpoint. Known values are: "unknown", "healthy", "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthStatus """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, **kwargs ): """ @@ -411,16 +385,16 @@ def __init__( is not accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have - been delivered to or rejected from this endpoint. Possible values include: "unknown", - "healthy", "unhealthy", "dead". + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthStatus """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -432,79 +406,67 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EnrichmentProperties(msrest.serialization.Model): +class EnrichmentProperties(_serialization.Model): """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. All required parameters must be populated in order to send to Azure. - :ivar key: Required. The key or name for the enrichment property. + :ivar key: The key or name for the enrichment property. Required. :vartype key: str - :ivar value: Required. The value for the enrichment property. + :ivar value: The value for the enrichment property. Required. :vartype value: str - :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. :vartype endpoint_names: list[str] """ _validation = { - 'key': {'required': True}, - 'value': {'required': True}, - 'endpoint_names': {'required': True, 'min_items': 1}, + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, } _attribute_map = { - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, } - def __init__( - self, - *, - key: str, - value: str, - endpoint_names: List[str], - **kwargs - ): + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs): """ - :keyword key: Required. The key or name for the enrichment property. + :keyword key: The key or name for the enrichment property. Required. :paramtype key: str - :keyword value: Required. The value for the enrichment property. + :keyword value: The value for the enrichment property. Required. :paramtype value: str - :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. :paramtype endpoint_names: list[str] """ - super(EnrichmentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.value = value self.endpoint_names = endpoint_names -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -520,33 +482,29 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -564,31 +522,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, str] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -596,7 +549,7 @@ def __init__( self.etag = None -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -608,37 +561,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -652,36 +600,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -689,34 +633,34 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool :ivar export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :vartype export_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, - 'export_blob_name': {'key': 'exportBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, + "export_blob_name": {"key": "exportBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, } def __init__( @@ -725,62 +669,57 @@ def __init__( export_blob_container_uri: str, exclude_keys: bool, export_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs ): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool :keyword export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :paramtype export_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys self.export_blob_name = export_blob_name self.authentication_type = authentication_type -class FailoverInput(msrest.serialization.Model): +class FailoverInput(_serialization.Model): """Use to provide failover region when requesting manual Failover for a hub. All required parameters must be populated in order to send to Azure. - :ivar failover_region: Required. Region the hub will be failed over to. + :ivar failover_region: Region the hub will be failed over to. Required. :vartype failover_region: str """ _validation = { - 'failover_region': {'required': True}, + "failover_region": {"required": True}, } _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, + "failover_region": {"key": "failoverRegion", "type": "str"}, } - def __init__( - self, - *, - failover_region: str, - **kwargs - ): + def __init__(self, *, failover_region: str, **kwargs): """ - :keyword failover_region: Required. Region the hub will be failed over to. + :keyword failover_region: Region the hub will be failed over to. Required. :paramtype failover_region: str """ - super(FailoverInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_region = failover_region -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -788,39 +727,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -831,21 +770,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -853,7 +792,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -870,13 +809,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -900,13 +839,13 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class GroupIdInformation(msrest.serialization.Model): +class GroupIdInformation(_serialization.Model): """The group information for creating a private endpoint on an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -919,42 +858,37 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties for a group information object. + :ivar properties: The properties for a group information object. Required. :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformationProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'GroupIdInformationProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, } - def __init__( - self, - *, - properties: "GroupIdInformationProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs): """ - :keyword properties: Required. The properties for a group information object. + :keyword properties: The properties for a group information object. Required. :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformationProperties """ - super(GroupIdInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class GroupIdInformationProperties(msrest.serialization.Model): +class GroupIdInformationProperties(_serialization.Model): """The properties for a group information object. :ivar group_id: The group id. @@ -966,9 +900,9 @@ class GroupIdInformationProperties(msrest.serialization.Model): """ _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, } def __init__( @@ -987,20 +921,20 @@ def __init__( :keyword required_zone_names: The required DNS zones for a specific group id. :paramtype required_zone_names: list[str] """ - super(GroupIdInformationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = group_id self.required_members = required_members self.required_zone_names = required_zone_names -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1008,21 +942,21 @@ class ImportDevicesRequest(msrest.serialization.Model): :ivar output_blob_name: The blob name to use for storing the status of the import job. :vartype output_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, - 'input_blob_name': {'key': 'inputBlobName', 'type': 'str'}, - 'output_blob_name': {'key': 'outputBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, + "input_blob_name": {"key": "inputBlobName", "type": "str"}, + "output_blob_name": {"key": "outputBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, } def __init__( @@ -1032,13 +966,13 @@ def __init__( output_blob_container_uri: str, input_blob_name: Optional[str] = None, output_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs ): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str :keyword input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1046,10 +980,10 @@ def __init__( :keyword output_blob_name: The blob name to use for storing the status of the import job. :paramtype output_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri self.input_blob_name = input_blob_name @@ -1057,50 +991,46 @@ def __init__( self.authentication_type = authentication_type -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1113,41 +1043,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1168,68 +1092,68 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, + properties: Optional["_models.IotHubProperties"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1241,51 +1165,46 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubLocationDescription(msrest.serialization.Model): +class IotHubLocationDescription(_serialization.Model): """Public representation of one of the locations where a resource is provisioned. :ivar location: The name of the Azure region. :vartype location: str :ivar role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery - (DR) paired region and also the region where the IoT hub can failover to. Possible values - include: "primary", "secondary". + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". :vartype role: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubReplicaRoleType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, **kwargs ): """ @@ -1293,57 +1212,51 @@ def __init__( :paramtype location: str :keyword role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster - recovery (DR) paired region and also the region where the IoT hub can failover to. Possible - values include: "primary", "secondary". + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". :paramtype role: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubReplicaRoleType """ - super(IotHubLocationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.role = role -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1352,8 +1265,8 @@ class IotHubProperties(msrest.serialization.Model): the IoT hub. :vartype authorization_policies: list[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] - :ivar public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.iothub.v2020_03_01.models.PublicNetworkAccess :ivar ip_filter_rules: The IP filter rules. @@ -1395,56 +1308,56 @@ class IotHubProperties(msrest.serialization.Model): :vartype cloud_to_device: ~azure.mgmt.iothub.v2020_03_01.models.CloudToDeviceProperties :ivar comments: IoT hub comments. :vartype comments: str - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2020_03_01.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubLocationDescription] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, - 'locations': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'min_tls_version': {'key': 'minTlsVersion', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'features': {'key': 'features', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "min_tls_version": {"key": "minTlsVersion", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "features": {"key": "features", "type": "str"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, min_tls_version: Optional[str] = None, - private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - features: Optional[Union[str, "Capabilities"]] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1452,8 +1365,8 @@ def __init__( to the IoT hub. :paramtype authorization_policies: list[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] - :keyword public_network_access: Whether requests from Public Network are allowed. Possible - values include: "Enabled", "Disabled". + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.iothub.v2020_03_01.models.PublicNetworkAccess :keyword ip_filter_rules: The IP filter rules. @@ -1489,11 +1402,11 @@ def __init__( :paramtype cloud_to_device: ~azure.mgmt.iothub.v2020_03_01.models.CloudToDeviceProperties :keyword comments: IoT hub comments. :paramtype comments: str - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2020_03_01.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.public_network_access = public_network_access self.ip_filter_rules = ip_filter_rules @@ -1513,7 +1426,7 @@ def __init__( self.locations = None -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1521,36 +1434,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1562,30 +1471,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1594,44 +1498,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2020_03_01.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2020_03_01.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1643,131 +1541,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2020_03_01.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2020_03_01.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1778,12 +1658,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2020_03_01.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2020_03_01.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -1794,34 +1674,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -1832,7 +1708,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1844,30 +1720,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -1875,24 +1746,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -1908,13 +1774,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1937,13 +1803,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -1953,29 +1819,23 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1987,30 +1847,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2020_03_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2026,64 +1881,55 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -2095,27 +1941,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The private endpoint property of a private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2125,24 +1967,20 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class PrivateEndpointConnection(msrest.serialization.Model): +class PrivateEndpointConnection(_serialization.Model): """The private endpoint connection of an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -2155,85 +1993,83 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties of a private endpoint connection. + :ivar properties: The properties of a private endpoint connection. Required. :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnectionProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, } - def __init__( - self, - *, - properties: "PrivateEndpointConnectionProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs): """ - :keyword properties: Required. The properties of a private endpoint connection. + :keyword properties: The properties of a private endpoint connection. Required. :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnectionProperties """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class PrivateEndpointConnectionProperties(msrest.serialization.Model): +class PrivateEndpointConnectionProperties(_serialization.Model): """The properties of a private endpoint connection. All required parameters must be populated in order to send to Azure. :ivar private_endpoint: The private endpoint property of a private endpoint connection. :vartype private_endpoint: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpoint - :ivar private_link_service_connection_state: Required. The current state of a private endpoint - connection. + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionState """ _validation = { - 'private_link_service_connection_state': {'required': True}, + "private_link_service_connection_state": {"required": True}, } _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, } def __init__( self, *, - private_link_service_connection_state: "PrivateLinkServiceConnectionState", - private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, **kwargs ): """ :keyword private_endpoint: The private endpoint property of a private endpoint connection. :paramtype private_endpoint: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpoint - :keyword private_link_service_connection_state: Required. The current state of a private - endpoint connection. + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. :paramtype private_link_service_connection_state: ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state -class PrivateLinkResources(msrest.serialization.Model): +class PrivateLinkResources(_serialization.Model): """The available private link resources for an IotHub. :ivar value: The list of available private link resources for an IotHub. @@ -2241,152 +2077,143 @@ class PrivateLinkResources(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, + "value": {"key": "value", "type": "[GroupIdInformation]"}, } - def __init__( - self, - *, - value: Optional[List["GroupIdInformation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs): """ :keyword value: The list of available private link resources for an IotHub. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformation] """ - super(PrivateLinkResources, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The current state of a private endpoint connection. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionStatus - :ivar description: Required. The description for the current state of a private endpoint - connection. + :ivar description: The description for the current state of a private endpoint connection. + Required. :vartype description: str :ivar actions_required: Actions required for a private endpoint connection. :vartype actions_required: str """ _validation = { - 'status': {'required': True}, - 'description': {'required': True}, + "status": {"required": True}, + "description": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Union[str, "PrivateLinkServiceConnectionStatus"], + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], description: str, actions_required: Optional[str] = None, **kwargs ): """ - :keyword status: Required. The status of a private endpoint connection. Possible values - include: "Pending", "Approved", "Rejected", "Disconnected". + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionStatus - :keyword description: Required. The description for the current state of a private endpoint - connection. + :keyword description: The description for the current state of a private endpoint connection. + Required. :paramtype description: str :keyword actions_required: Actions required for a private endpoint connection. :paramtype actions_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -2396,29 +2223,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -2428,15 +2249,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -2445,79 +2266,79 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2525,7 +2346,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2546,19 +2367,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -2578,14 +2399,14 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2020_03_01.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. @@ -2598,13 +2419,13 @@ class RoutingEventHubProperties(msrest.serialization.Model): :vartype endpoint_uri: str :ivar entity_path: Event hub name on the event hub namespace. :vartype entity_path: str - :ivar authentication_type: Method used to authenticate against the event hub endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -2613,29 +2434,29 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -2649,20 +2470,20 @@ def __init__( :paramtype endpoint_uri: str :keyword entity_path: Event hub name on the event hub namespace. :paramtype entity_path: str - :keyword authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -2673,7 +2494,7 @@ def __init__( self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -2685,9 +2506,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -2706,13 +2527,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -2735,19 +2556,19 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - 'enrichments': {'key': 'enrichments', 'type': '[EnrichmentProperties]'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, - enrichments: Optional[List["EnrichmentProperties"]] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, **kwargs ): """ @@ -2770,14 +2591,14 @@ def __init__( https://aka.ms/telemetryoneventgrid. :paramtype enrichments: list[~azure.mgmt.iothub.v2020_03_01.models.EnrichmentProperties] """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route self.enrichments = enrichments -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. @@ -2792,13 +2613,12 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus namespace. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -2807,29 +2627,29 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -2845,20 +2665,19 @@ def __init__( :keyword entity_path: Queue name on the service bus namespace. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus queue - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -2869,7 +2688,7 @@ def __init__( self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. @@ -2884,13 +2703,13 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus topic. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -2899,29 +2718,29 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -2937,20 +2756,20 @@ def __init__( :keyword entity_path: Queue name on the service bus topic. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus topic - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -2961,7 +2780,7 @@ def __init__( self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. @@ -2972,19 +2791,19 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): :vartype connection_string: str :ivar endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :vartype endpoint_uri: str - :ivar authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -2997,32 +2816,32 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :vartype max_chunk_size_in_bytes: int :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :vartype encoding: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingStorageContainerPropertiesEncoding """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -3030,16 +2849,16 @@ def __init__( *, name: str, container_name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, file_name_format: Optional[str] = None, batch_frequency_in_seconds: Optional[int] = None, max_chunk_size_in_bytes: Optional[int] = None, - encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): """ @@ -3049,19 +2868,19 @@ def __init__( :paramtype connection_string: str :keyword endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :paramtype endpoint_uri: str - :keyword authentication_type: Method used to authenticate against the storage endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3074,12 +2893,12 @@ def __init__( Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :paramtype max_chunk_size_in_bytes: int :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :paramtype encoding: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingStorageContainerPropertiesEncoding """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3094,136 +2913,126 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired: Twin desired properties. - :vartype desired: any + :vartype desired: JSON :ivar reported: Twin desired properties. - :vartype reported: any + :vartype reported: JSON """ _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, } - def __init__( - self, - *, - desired: Optional[Any] = None, - reported: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): """ :keyword desired: Twin desired properties. - :paramtype desired: any + :paramtype desired: JSON :keyword reported: Twin desired properties. - :paramtype reported: any + :paramtype reported: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired = desired self.reported = reported -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2020_03_01.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2020_03_01.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -3236,31 +3045,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -3269,27 +3073,27 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, } def __init__( @@ -3298,7 +3102,7 @@ def __init__( connection_string: str, container_name: str, sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs ): """ @@ -3306,53 +3110,48 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name self.authentication_type = authentication_type -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage @@ -3361,35 +3160,35 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", and "DeviceJobLifecycleEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -3397,102 +3196,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2020_03_01.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2020_03_01.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2020_03_01.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -3500,25 +3293,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2020_03_01.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -3536,23 +3324,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -3569,7 +3357,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2020_03_01.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -3578,7 +3366,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3590,24 +3378,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py index a7ea4e625cfd..465d80933309 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateBodyDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2020_03_01.models.CertificateBodyDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateBodyDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: ~azure.mgmt.iothub.v2020_03_01.models.CertificateBodyDescription + or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateBodyDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py index 3558c1d9573b..de2daa8f0631 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,141 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_manual_failover_request_initial( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class IotHubOperations(object): - """IotHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _manual_failover_initial( + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") - request = build_manual_failover_request_initial( + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2020_03_01.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> LROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -147,14 +237,18 @@ def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2020_03_01.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2020_03_01.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -165,43 +259,48 @@ def begin_manual_failover( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._manual_failover_initial( + raw_result = self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py index b197c51cfc67..7f40389a06ac 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,967 +6,839 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2020-03-01" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -973,76 +846,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -1051,15 +940,18 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1071,114 +963,222 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2020_03_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1190,111 +1190,186 @@ def begin_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2020_03_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1304,90 +1379,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription - or ~azure.mgmt.iothub.v2020_03_01.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1401,7 +1482,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1411,56 +1494,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1474,7 +1555,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1484,49 +1567,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1534,65 +1618,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1606,7 +1691,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,68 +1703,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1691,7 +1776,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1701,57 +1788,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1759,61 +1848,64 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def create_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.create_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1821,61 +1913,64 @@ def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1886,60 +1981,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1953,7 +2045,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1963,55 +2057,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2019,65 +2113,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2091,7 +2186,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2101,61 +2198,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2169,7 +2264,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2179,50 +2276,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2020_03_01.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2020_03_01.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(operation_inputs, 'OperationInputs') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2230,61 +2381,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(input, 'TestAllRoutesInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2292,61 +2514,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(input, 'TestRouteInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2354,67 +2647,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2428,7 +2722,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2438,55 +2734,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2494,24 +2792,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2520,39 +2819,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2020_03_01.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2020_03_01.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2560,24 +2945,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2586,39 +2972,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2020_03_01.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2020_03_01.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2626,12 +3098,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py index 505155cfd60b..93ca0ce48805 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py index ade8c39c7b02..71799d04bd87 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,242 +6,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2020-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -248,57 +251,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,89 +312,109 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -401,114 +427,201 @@ def begin_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -522,44 +635,48 @@ def begin_delete( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py index d4327dfb078a..966de1aa52b3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,156 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,57 +162,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -220,12 +223,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py index 5511313d433e..f830f05fdad4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2020-03-01" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2020_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2020_03_01.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py index 4c19507767b9..5d208c2c03e0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-03-03-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-03-03-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-03-03-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py index 228c19ee302c..b59f116c1153 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -42,12 +51,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_03_03_preview.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-03-03-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -68,18 +80,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +101,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_metadata.json index 89c74400d8bf..254652ee5a93 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py index 8c2881ceb63e..ffb616eb5315 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-03-03-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-03-03-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-03-03-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py index 0a2596c56ef8..1670f1f8898b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -43,12 +52,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_03_03_preview.aio.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-03-03-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -69,18 +81,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -89,7 +102,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py index ae289fc0cd12..e03c72c77210 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,87 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,55 +254,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateDescription", + certificate_description: Union[_models.CertificateDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: - ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -219,64 +330,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -287,55 +400,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -343,15 +458,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -360,54 +547,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -415,12 +621,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py index fab7afcbc92c..3834fd6d4644 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_operations import build_manual_failover_request_initial -T = TypeVar('T') +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubOperations: - """IotHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.aio.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _manual_failover_initial( + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_03_03_preview.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -100,14 +200,18 @@ async def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2021_03_03_preview.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_03_03_preview.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -118,43 +222,48 @@ async def begin_manual_failover( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._manual_failover_initial( + raw_result = await self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py index 9aa4244ff357..5c76e5239f71 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,91 +125,198 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription or + IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -189,114 +329,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_03_preview.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -309,111 +468,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_03_preview.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -423,91 +659,99 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription - or ~azure.mgmt.iothub.v2021_03_03_preview.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -521,7 +765,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -531,56 +777,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -594,7 +841,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -604,49 +853,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,65 +906,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -726,7 +979,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -736,68 +991,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -811,7 +1064,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,57 +1076,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -879,15 +1136,87 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_event_hub_consumer_group( @@ -896,53 +1225,73 @@ async def create_event_hub_consumer_group( resource_name: str, event_hub_endpoint_name: str, name: str, - consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str - :param consumer_group_body: The consumer group to add. + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. :type consumer_group_body: - ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription + ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_event_hub_consumer_group.metadata['url'], + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -950,61 +1299,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1015,60 +1367,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1082,7 +1434,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1092,55 +1446,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1148,65 +1504,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1220,7 +1577,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1230,61 +1589,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1298,7 +1656,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1308,50 +1668,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. - _json = self._serialize.body(operation_inputs, 'OperationInputs') + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1359,61 +1773,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(input, 'TestAllRoutesInput') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1421,61 +1906,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore - + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. - _json = self._serialize.body(input, 'TestRouteInput') + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1483,67 +2039,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1557,7 +2114,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1567,55 +2126,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1623,24 +2184,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1649,40 +2211,126 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2021_03_03_preview.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2021_03_03_preview.models.ExportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1690,24 +2338,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1716,40 +2365,126 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2021_03_03_preview.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2021_03_03_preview.models.ImportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1757,12 +2492,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py index 7fe0153d081c..6b1aeea492d7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py index 360476c9c1e9..7d419ac5fe62 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.aio.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,57 +105,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,89 +166,109 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -243,114 +281,201 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -364,44 +489,48 @@ async def begin_delete( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py index 4ec5d7fa9f28..9e656850826d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.aio.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +96,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,12 +157,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py index f7e828fb0140..33f7f3b6b823 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/__init__.py index 61dab75c6643..3d708a8a05a2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/__init__.py @@ -91,135 +91,137 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - AuthenticationType, - Capabilities, - DefaultAction, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - NetworkRuleIPAction, - PrivateLinkServiceConnectionStatus, - PublicNetworkAccess, - ResourceIdentityType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import AuthenticationType +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import DefaultAction +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import NetworkRuleIPAction +from ._iot_hub_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_hub_client_enums import PublicNetworkAccess +from ._iot_hub_client_enums import ResourceIdentityType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ArmIdentity', - 'ArmUserIdentity', - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EncryptionPropertiesDescription', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'EnrichmentProperties', - 'ErrorDetails', - 'EventHubConsumerGroupBodyDescription', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupName', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FailoverInput', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'GroupIdInformation', - 'GroupIdInformationProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubLocationDescription', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubPropertiesDeviceStreams', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'KeyVaultKeyProperties', - 'ManagedIdentity', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'NetworkRuleSetIpRule', - 'NetworkRuleSetProperties', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionProperties', - 'PrivateLinkResources', - 'PrivateLinkServiceConnectionState', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'AuthenticationType', - 'Capabilities', - 'DefaultAction', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubReplicaRoleType', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'NetworkRuleIPAction', - 'PrivateLinkServiceConnectionStatus', - 'PublicNetworkAccess', - 'ResourceIdentityType', - 'RouteErrorSeverity', - 'RoutingSource', - 'RoutingStorageContainerPropertiesEncoding', - 'TestResultStatus', + "ArmIdentity", + "ArmUserIdentity", + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EncryptionPropertiesDescription", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupBodyDescription", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupName", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "GroupIdInformation", + "GroupIdInformationProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubPropertiesDeviceStreams", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "KeyVaultKeyProperties", + "ManagedIdentity", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "NetworkRuleSetIpRule", + "NetworkRuleSetProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "AuthenticationType", + "Capabilities", + "DefaultAction", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "NetworkRuleIPAction", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "ResourceIdentityType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py index a8c0e3a0f3e6..ee6a65a17273 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,30 +27,33 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Specifies authentication type being used for connecting to the storage account. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies authentication type being used for connecting to the storage account.""" KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Default Action for Network Rule Set - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default Action for Network Rule Set.""" DENY = "Deny" ALLOW = "Allow" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Health statuses have following meanings. The 'healthy' status shows that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an @@ -61,7 +62,7 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or - rejected from this endpoint + rejected from this endpoint. """ UNKNOWN = "unknown" @@ -70,14 +71,15 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired region and also the region where the IoT hub can failover to. @@ -86,17 +88,17 @@ class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -106,24 +108,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -132,13 +134,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -147,29 +149,30 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """IP Filter Action - """ + +class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP Filter Action.""" ALLOW = "Allow" -class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of a private endpoint connection - """ + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether requests from Public Network are allowed - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. @@ -180,16 +183,16 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -199,7 +202,8 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DIGITAL_TWIN_CHANGE_EVENTS = "DigitalTwinChangeEvents" DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -208,9 +212,9 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEn AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py index 15e24f718b19..9e6beadb385f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ArmIdentity(msrest.serialization.Model): +class ArmIdentity(_serialization.Model): """ArmIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,8 +34,8 @@ class ArmIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the service. Possible values include: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + 'None' will remove any identities from the service. Known values are: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.ResourceIdentityType :ivar user_assigned_identities: Dictionary of :code:``. :vartype user_assigned_identities: dict[str, @@ -35,42 +43,42 @@ class ArmIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ArmUserIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{ArmUserIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ArmUserIdentity"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ArmUserIdentity"]] = None, **kwargs ): """ :keyword type: The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the service. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + assigned identities. The type 'None' will remove any identities from the service. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.ResourceIdentityType :keyword user_assigned_identities: Dictionary of :code:``. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmUserIdentity] """ - super(ArmIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class ArmUserIdentity(msrest.serialization.Model): +class ArmUserIdentity(_serialization.Model): """ArmUserIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -82,27 +90,23 @@ class ArmUserIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ArmUserIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -111,25 +115,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -147,31 +146,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -179,7 +173,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -187,24 +181,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -226,35 +215,30 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -264,7 +248,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -289,34 +273,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -327,7 +307,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -336,25 +316,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -374,33 +349,28 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -408,7 +378,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -424,13 +394,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -438,7 +408,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -453,13 +423,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2021_03_03_preview.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EncryptionPropertiesDescription(msrest.serialization.Model): +class EncryptionPropertiesDescription(_serialization.Model): """The encryption properties for the IoT hub. :ivar key_source: The source of the key. @@ -470,15 +440,15 @@ class EncryptionPropertiesDescription(msrest.serialization.Model): """ _attribute_map = { - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultKeyProperties]'}, + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultKeyProperties]"}, } def __init__( self, *, key_source: Optional[str] = None, - key_vault_properties: Optional[List["KeyVaultKeyProperties"]] = None, + key_vault_properties: Optional[List["_models.KeyVaultKeyProperties"]] = None, **kwargs ): """ @@ -488,12 +458,12 @@ def __init__( :paramtype key_vault_properties: list[~azure.mgmt.iothub.v2021_03_03_preview.models.KeyVaultKeyProperties] """ - super(EncryptionPropertiesDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_source = key_source self.key_vault_properties = key_vault_properties -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. @@ -506,8 +476,8 @@ class EndpointHealthData(msrest.serialization.Model): accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered - to or rejected from this endpoint. Possible values include: "unknown", "healthy", "degraded", - "unhealthy", "dead". + to or rejected from this endpoint. Known values are: "unknown", "healthy", "degraded", + "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthStatus :ivar last_known_error: Last error obtained when a message failed to be delivered to iot hub. @@ -522,19 +492,19 @@ class EndpointHealthData(msrest.serialization.Model): """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, - 'last_known_error': {'key': 'lastKnownError', 'type': 'str'}, - 'last_known_error_time': {'key': 'lastKnownErrorTime', 'type': 'rfc-1123'}, - 'last_successful_send_attempt_time': {'key': 'lastSuccessfulSendAttemptTime', 'type': 'rfc-1123'}, - 'last_send_attempt_time': {'key': 'lastSendAttemptTime', 'type': 'rfc-1123'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, + "last_known_error": {"key": "lastKnownError", "type": "str"}, + "last_known_error_time": {"key": "lastKnownErrorTime", "type": "rfc-1123"}, + "last_successful_send_attempt_time": {"key": "lastSuccessfulSendAttemptTime", "type": "rfc-1123"}, + "last_send_attempt_time": {"key": "lastSendAttemptTime", "type": "rfc-1123"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, last_known_error: Optional[str] = None, last_known_error_time: Optional[datetime.datetime] = None, last_successful_send_attempt_time: Optional[datetime.datetime] = None, @@ -552,8 +522,8 @@ def __init__( is not accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have - been delivered to or rejected from this endpoint. Possible values include: "unknown", - "healthy", "degraded", "unhealthy", "dead". + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "degraded", "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthStatus :keyword last_known_error: Last error obtained when a message failed to be delivered to iot @@ -567,7 +537,7 @@ def __init__( :keyword last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. :paramtype last_send_attempt_time: ~datetime.datetime """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status self.last_known_error = last_known_error @@ -576,7 +546,7 @@ def __init__( self.last_send_attempt_time = last_send_attempt_time -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -588,79 +558,67 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EnrichmentProperties(msrest.serialization.Model): +class EnrichmentProperties(_serialization.Model): """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. All required parameters must be populated in order to send to Azure. - :ivar key: Required. The key or name for the enrichment property. + :ivar key: The key or name for the enrichment property. Required. :vartype key: str - :ivar value: Required. The value for the enrichment property. + :ivar value: The value for the enrichment property. Required. :vartype value: str - :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. :vartype endpoint_names: list[str] """ _validation = { - 'key': {'required': True}, - 'value': {'required': True}, - 'endpoint_names': {'required': True, 'min_items': 1}, + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, } _attribute_map = { - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, } - def __init__( - self, - *, - key: str, - value: str, - endpoint_names: List[str], - **kwargs - ): + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs): """ - :keyword key: Required. The key or name for the enrichment property. + :keyword key: The key or name for the enrichment property. Required. :paramtype key: str - :keyword value: Required. The value for the enrichment property. + :keyword value: The value for the enrichment property. Required. :paramtype value: str - :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. :paramtype endpoint_names: list[str] """ - super(EnrichmentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.value = value self.endpoint_names = endpoint_names -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -676,33 +634,29 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): +class EventHubConsumerGroupBodyDescription(_serialization.Model): """The EventHub consumer group. :ivar properties: The EventHub consumer group name. @@ -710,24 +664,19 @@ class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'EventHubConsumerGroupName'}, + "properties": {"key": "properties", "type": "EventHubConsumerGroupName"}, } - def __init__( - self, - *, - properties: Optional["EventHubConsumerGroupName"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.EventHubConsumerGroupName"] = None, **kwargs): """ :keyword properties: The EventHub consumer group name. :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupName """ - super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -745,31 +694,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, str] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -777,7 +721,7 @@ def __init__( self.etag = None -class EventHubConsumerGroupName(msrest.serialization.Model): +class EventHubConsumerGroupName(_serialization.Model): """The EventHub consumer group name. :ivar name: EventHub consumer group name. @@ -785,24 +729,19 @@ class EventHubConsumerGroupName(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: EventHub consumer group name. :paramtype name: str """ - super(EventHubConsumerGroupName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -814,37 +753,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -858,36 +792,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -895,21 +825,21 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool :ivar export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :vartype export_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for export devices. @@ -917,16 +847,16 @@ class ExportDevicesRequest(msrest.serialization.Model): """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, - 'export_blob_name': {'key': 'exportBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, + "export_blob_name": {"key": "exportBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, } def __init__( @@ -935,28 +865,28 @@ def __init__( export_blob_container_uri: str, exclude_keys: bool, export_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, **kwargs ): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool :keyword export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :paramtype export_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for export devices. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys self.export_blob_name = export_blob_name @@ -964,38 +894,33 @@ def __init__( self.identity = identity -class FailoverInput(msrest.serialization.Model): +class FailoverInput(_serialization.Model): """Use to provide failover region when requesting manual Failover for a hub. All required parameters must be populated in order to send to Azure. - :ivar failover_region: Required. Region the hub will be failed over to. + :ivar failover_region: Region the hub will be failed over to. Required. :vartype failover_region: str """ _validation = { - 'failover_region': {'required': True}, + "failover_region": {"required": True}, } _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, + "failover_region": {"key": "failoverRegion", "type": "str"}, } - def __init__( - self, - *, - failover_region: str, - **kwargs - ): + def __init__(self, *, failover_region: str, **kwargs): """ - :keyword failover_region: Required. Region the hub will be failed over to. + :keyword failover_region: Region the hub will be failed over to. Required. :paramtype failover_region: str """ - super(FailoverInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_region = failover_region -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -1003,40 +928,40 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", and "DeviceConnectionStateEvents". :vartype source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -1047,22 +972,22 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", and + "DeviceConnectionStateEvents". :paramtype source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -1070,7 +995,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -1087,13 +1012,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1117,13 +1042,13 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class GroupIdInformation(msrest.serialization.Model): +class GroupIdInformation(_serialization.Model): """The group information for creating a private endpoint on an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1136,43 +1061,38 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties for a group information object. + :ivar properties: The properties for a group information object. Required. :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformationProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'GroupIdInformationProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, } - def __init__( - self, - *, - properties: "GroupIdInformationProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs): """ - :keyword properties: Required. The properties for a group information object. + :keyword properties: The properties for a group information object. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformationProperties """ - super(GroupIdInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class GroupIdInformationProperties(msrest.serialization.Model): +class GroupIdInformationProperties(_serialization.Model): """The properties for a group information object. :ivar group_id: The group id. @@ -1184,9 +1104,9 @@ class GroupIdInformationProperties(msrest.serialization.Model): """ _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, } def __init__( @@ -1205,20 +1125,20 @@ def __init__( :keyword required_zone_names: The required DNS zones for a specific group id. :paramtype required_zone_names: list[str] """ - super(GroupIdInformationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = group_id self.required_members = required_members self.required_zone_names = required_zone_names -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1226,7 +1146,7 @@ class ImportDevicesRequest(msrest.serialization.Model): :ivar output_blob_name: The blob name to use for storing the status of the import job. :vartype output_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for import devices. @@ -1234,17 +1154,17 @@ class ImportDevicesRequest(msrest.serialization.Model): """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, - 'input_blob_name': {'key': 'inputBlobName', 'type': 'str'}, - 'output_blob_name': {'key': 'outputBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, + "input_blob_name": {"key": "inputBlobName", "type": "str"}, + "output_blob_name": {"key": "outputBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, } def __init__( @@ -1254,14 +1174,14 @@ def __init__( output_blob_container_uri: str, input_blob_name: Optional[str] = None, output_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, **kwargs ): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str :keyword input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1269,13 +1189,13 @@ def __init__( :keyword output_blob_name: The blob name to use for storing the status of the import job. :paramtype output_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for import devices. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri self.input_blob_name = input_blob_name @@ -1284,50 +1204,46 @@ def __init__( self.identity = identity -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1340,41 +1256,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1395,75 +1305,75 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo :ivar identity: The managed identities for the IotHub. :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmIdentity """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'identity': {'key': 'identity', 'type': 'ArmIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "identity": {"key": "identity", "type": "ArmIdentity"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, - identity: Optional["ArmIdentity"] = None, + properties: Optional["_models.IotHubProperties"] = None, + identity: Optional["_models.ArmIdentity"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo :keyword identity: The managed identities for the IotHub. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmIdentity """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku self.identity = identity -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1475,51 +1385,46 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubLocationDescription(msrest.serialization.Model): +class IotHubLocationDescription(_serialization.Model): """Public representation of one of the locations where a resource is provisioned. :ivar location: The name of the Azure region. :vartype location: str :ivar role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery - (DR) paired region and also the region where the IoT hub can failover to. Possible values - include: "primary", "secondary". + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". :vartype role: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubReplicaRoleType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, **kwargs ): """ @@ -1527,24 +1432,23 @@ def __init__( :paramtype location: str :keyword role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster - recovery (DR) paired region and also the region where the IoT hub can failover to. Possible - values include: "primary", "secondary". + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". :paramtype role: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubReplicaRoleType """ - super(IotHubLocationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.role = role -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. @@ -1552,33 +1456,28 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1587,8 +1486,8 @@ class IotHubProperties(msrest.serialization.Model): the IoT hub. :vartype authorization_policies: list[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] - :ivar public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.PublicNetworkAccess :ivar ip_filter_rules: The IP filter rules. @@ -1636,8 +1535,8 @@ class IotHubProperties(msrest.serialization.Model): :ivar device_streams: The device streams properties of iothub. :vartype device_streams: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubPropertiesDeviceStreams - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.Capabilities :ivar encryption: The encryption properties for the IoT hub. :vartype encryption: @@ -1648,54 +1547,54 @@ class IotHubProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, - 'locations': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'network_rule_sets': {'key': 'networkRuleSets', 'type': 'NetworkRuleSetProperties'}, - 'min_tls_version': {'key': 'minTlsVersion', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'device_streams': {'key': 'deviceStreams', 'type': 'IotHubPropertiesDeviceStreams'}, - 'features': {'key': 'features', 'type': 'str'}, - 'encryption': {'key': 'encryption', 'type': 'EncryptionPropertiesDescription'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, - } - - def __init__( - self, - *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - network_rule_sets: Optional["NetworkRuleSetProperties"] = None, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "network_rule_sets": {"key": "networkRuleSets", "type": "NetworkRuleSetProperties"}, + "min_tls_version": {"key": "minTlsVersion", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "device_streams": {"key": "deviceStreams", "type": "IotHubPropertiesDeviceStreams"}, + "features": {"key": "features", "type": "str"}, + "encryption": {"key": "encryption", "type": "EncryptionPropertiesDescription"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, + } + + def __init__( + self, + *, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + network_rule_sets: Optional["_models.NetworkRuleSetProperties"] = None, min_tls_version: Optional[str] = None, - private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - device_streams: Optional["IotHubPropertiesDeviceStreams"] = None, - features: Optional[Union[str, "Capabilities"]] = None, - encryption: Optional["EncryptionPropertiesDescription"] = None, + device_streams: Optional["_models.IotHubPropertiesDeviceStreams"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, + encryption: Optional["_models.EncryptionPropertiesDescription"] = None, **kwargs ): """ @@ -1703,8 +1602,8 @@ def __init__( to the IoT hub. :paramtype authorization_policies: list[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] - :keyword public_network_access: Whether requests from Public Network are allowed. Possible - values include: "Enabled", "Disabled". + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.PublicNetworkAccess :keyword ip_filter_rules: The IP filter rules. @@ -1747,14 +1646,14 @@ def __init__( :keyword device_streams: The device streams properties of iothub. :paramtype device_streams: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubPropertiesDeviceStreams - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.Capabilities :keyword encryption: The encryption properties for the IoT hub. :paramtype encryption: ~azure.mgmt.iothub.v2021_03_03_preview.models.EncryptionPropertiesDescription """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.public_network_access = public_network_access self.ip_filter_rules = ip_filter_rules @@ -1777,7 +1676,7 @@ def __init__( self.locations = None -class IotHubPropertiesDeviceStreams(msrest.serialization.Model): +class IotHubPropertiesDeviceStreams(_serialization.Model): """The device streams properties of iothub. :ivar streaming_endpoints: List of Device Streams Endpoints. @@ -1785,24 +1684,19 @@ class IotHubPropertiesDeviceStreams(msrest.serialization.Model): """ _attribute_map = { - 'streaming_endpoints': {'key': 'streamingEndpoints', 'type': '[str]'}, + "streaming_endpoints": {"key": "streamingEndpoints", "type": "[str]"}, } - def __init__( - self, - *, - streaming_endpoints: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, streaming_endpoints: Optional[List[str]] = None, **kwargs): """ :keyword streaming_endpoints: List of Device Streams Endpoints. :paramtype streaming_endpoints: list[str] """ - super(IotHubPropertiesDeviceStreams, self).__init__(**kwargs) + super().__init__(**kwargs) self.streaming_endpoints = streaming_endpoints -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1810,36 +1704,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1851,30 +1741,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1883,44 +1768,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1932,131 +1811,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2067,12 +1928,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -2083,34 +1944,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -2121,7 +1978,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2133,30 +1990,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class KeyVaultKeyProperties(msrest.serialization.Model): +class KeyVaultKeyProperties(_serialization.Model): """The properties of the KeyVault key. :ivar key_identifier: The identifier of the key. @@ -2166,16 +2018,12 @@ class KeyVaultKeyProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, } def __init__( - self, - *, - key_identifier: Optional[str] = None, - identity: Optional["ManagedIdentity"] = None, - **kwargs + self, *, key_identifier: Optional[str] = None, identity: Optional["_models.ManagedIdentity"] = None, **kwargs ): """ :keyword key_identifier: The identifier of the key. @@ -2183,12 +2031,12 @@ def __init__( :keyword identity: Managed identity properties of KeyVault Key. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity """ - super(KeyVaultKeyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.identity = identity -class ManagedIdentity(msrest.serialization.Model): +class ManagedIdentity(_serialization.Model): """The properties of the Managed identity. :ivar user_assigned_identity: The user assigned identity. @@ -2196,24 +2044,19 @@ class ManagedIdentity(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword user_assigned_identity: The user assigned identity. :paramtype user_assigned_identity: str """ - super(ManagedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -2221,24 +2064,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -2254,13 +2092,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -2283,13 +2121,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -2299,127 +2137,116 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class NetworkRuleSetIpRule(msrest.serialization.Model): +class NetworkRuleSetIpRule(_serialization.Model): """IP Rule to be applied as part of Network Rule Set. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. Name of the IP filter rule. + :ivar filter_name: Name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :ivar action: IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleIPAction - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } def __init__( - self, - *, - filter_name: str, - ip_mask: str, - action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, filter_name: str, ip_mask: str, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ - :keyword filter_name: Required. Name of the IP filter rule. + :keyword filter_name: Name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :keyword action: IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleIPAction - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(NetworkRuleSetIpRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class NetworkRuleSetProperties(msrest.serialization.Model): +class NetworkRuleSetProperties(_serialization.Model): """Network Rule Set Properties of IotHub. All required parameters must be populated in order to send to Azure. - :ivar default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". :vartype default_action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.DefaultAction - :ivar apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. + :ivar apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied to + BuiltIn EventHub EndPoint of IotHub. Required. :vartype apply_to_built_in_event_hub_endpoint: bool - :ivar ip_rules: Required. List of IP Rules. + :ivar ip_rules: List of IP Rules. Required. :vartype ip_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetIpRule] """ _validation = { - 'apply_to_built_in_event_hub_endpoint': {'required': True}, - 'ip_rules': {'required': True}, + "apply_to_built_in_event_hub_endpoint": {"required": True}, + "ip_rules": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'apply_to_built_in_event_hub_endpoint': {'key': 'applyToBuiltInEventHubEndpoint', 'type': 'bool'}, - 'ip_rules': {'key': 'ipRules', 'type': '[NetworkRuleSetIpRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "apply_to_built_in_event_hub_endpoint": {"key": "applyToBuiltInEventHubEndpoint", "type": "bool"}, + "ip_rules": {"key": "ipRules", "type": "[NetworkRuleSetIpRule]"}, } def __init__( self, *, apply_to_built_in_event_hub_endpoint: bool, - ip_rules: List["NetworkRuleSetIpRule"], - default_action: Optional[Union[str, "DefaultAction"]] = "Deny", + ip_rules: List["_models.NetworkRuleSetIpRule"], + default_action: Union[str, "_models.DefaultAction"] = "Deny", **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". + :keyword default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". :paramtype default_action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.DefaultAction - :keyword apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. + :keyword apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied + to BuiltIn EventHub EndPoint of IotHub. Required. :paramtype apply_to_built_in_event_hub_endpoint: bool - :keyword ip_rules: Required. List of IP Rules. + :keyword ip_rules: List of IP Rules. Required. :paramtype ip_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetIpRule] """ - super(NetworkRuleSetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint self.ip_rules = ip_rules -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2431,30 +2258,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2470,64 +2292,55 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -2539,27 +2352,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The private endpoint property of a private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2569,24 +2378,20 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class PrivateEndpointConnection(msrest.serialization.Model): +class PrivateEndpointConnection(_serialization.Model): """The private endpoint connection of an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -2599,86 +2404,84 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties of a private endpoint connection. + :ivar properties: The properties of a private endpoint connection. Required. :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnectionProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, } - def __init__( - self, - *, - properties: "PrivateEndpointConnectionProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs): """ - :keyword properties: Required. The properties of a private endpoint connection. + :keyword properties: The properties of a private endpoint connection. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnectionProperties """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class PrivateEndpointConnectionProperties(msrest.serialization.Model): +class PrivateEndpointConnectionProperties(_serialization.Model): """The properties of a private endpoint connection. All required parameters must be populated in order to send to Azure. :ivar private_endpoint: The private endpoint property of a private endpoint connection. :vartype private_endpoint: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpoint - :ivar private_link_service_connection_state: Required. The current state of a private endpoint - connection. + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionState """ _validation = { - 'private_link_service_connection_state': {'required': True}, + "private_link_service_connection_state": {"required": True}, } _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, } def __init__( self, *, - private_link_service_connection_state: "PrivateLinkServiceConnectionState", - private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, **kwargs ): """ :keyword private_endpoint: The private endpoint property of a private endpoint connection. :paramtype private_endpoint: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpoint - :keyword private_link_service_connection_state: Required. The current state of a private - endpoint connection. + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. :paramtype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state -class PrivateLinkResources(msrest.serialization.Model): +class PrivateLinkResources(_serialization.Model): """The available private link resources for an IotHub. :ivar value: The list of available private link resources for an IotHub. @@ -2686,152 +2489,143 @@ class PrivateLinkResources(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, + "value": {"key": "value", "type": "[GroupIdInformation]"}, } - def __init__( - self, - *, - value: Optional[List["GroupIdInformation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs): """ :keyword value: The list of available private link resources for an IotHub. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformation] """ - super(PrivateLinkResources, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The current state of a private endpoint connection. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionStatus - :ivar description: Required. The description for the current state of a private endpoint - connection. + :ivar description: The description for the current state of a private endpoint connection. + Required. :vartype description: str :ivar actions_required: Actions required for a private endpoint connection. :vartype actions_required: str """ _validation = { - 'status': {'required': True}, - 'description': {'required': True}, + "status": {"required": True}, + "description": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Union[str, "PrivateLinkServiceConnectionStatus"], + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], description: str, actions_required: Optional[str] = None, **kwargs ): """ - :keyword status: Required. The status of a private endpoint connection. Possible values - include: "Pending", "Approved", "Rejected", "Disconnected". + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionStatus - :keyword description: Required. The description for the current state of a private endpoint - connection. + :keyword description: The description for the current state of a private endpoint connection. + Required. :paramtype description: str :keyword actions_required: Actions required for a private endpoint connection. :paramtype actions_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -2841,29 +2635,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -2873,15 +2661,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -2890,81 +2678,81 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", and "DeviceConnectionStateEvents". :vartype source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", and "DeviceConnectionStateEvents". :paramtype source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2972,7 +2760,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2994,19 +2782,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -3027,14 +2815,14 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. @@ -3047,16 +2835,16 @@ class RoutingEventHubProperties(msrest.serialization.Model): :vartype endpoint_uri: str :ivar entity_path: Event hub name on the event hub namespace. :vartype entity_path: str - :ivar authentication_type: Method used to authenticate against the event hub endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :ivar identity: Managed identity properties of routing event hub endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -3065,31 +2853,31 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3103,23 +2891,23 @@ def __init__( :paramtype endpoint_uri: str :keyword entity_path: Event hub name on the event hub namespace. :paramtype entity_path: str - :keyword authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :keyword identity: Managed identity properties of routing event hub endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3131,7 +2919,7 @@ def __init__( self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -3143,9 +2931,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -3164,13 +2952,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -3193,19 +2981,19 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - 'enrichments': {'key': 'enrichments', 'type': '[EnrichmentProperties]'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, - enrichments: Optional[List["EnrichmentProperties"]] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, **kwargs ): """ @@ -3230,14 +3018,14 @@ def __init__( :paramtype enrichments: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EnrichmentProperties] """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route self.enrichments = enrichments -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. @@ -3252,16 +3040,15 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus namespace. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus queue endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -3270,31 +3057,31 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3310,23 +3097,22 @@ def __init__( :keyword entity_path: Queue name on the service bus namespace. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus queue - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus queue endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3338,7 +3124,7 @@ def __init__( self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. @@ -3353,16 +3139,16 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus topic. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus topic endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -3371,31 +3157,31 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3411,23 +3197,23 @@ def __init__( :keyword entity_path: Queue name on the service bus topic. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus topic - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus topic endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3439,7 +3225,7 @@ def __init__( self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. @@ -3450,22 +3236,22 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): :vartype connection_string: str :ivar endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :vartype endpoint_uri: str - :ivar authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :ivar identity: Managed identity properties of routing storage endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3478,33 +3264,33 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :vartype max_chunk_size_in_bytes: int :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :vartype encoding: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingStorageContainerPropertiesEncoding """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -3512,17 +3298,17 @@ def __init__( *, name: str, container_name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, file_name_format: Optional[str] = None, batch_frequency_in_seconds: Optional[int] = None, max_chunk_size_in_bytes: Optional[int] = None, - encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): """ @@ -3532,22 +3318,22 @@ def __init__( :paramtype connection_string: str :keyword endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :paramtype endpoint_uri: str - :keyword authentication_type: Method used to authenticate against the storage endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :keyword identity: Managed identity properties of routing storage endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3560,12 +3346,12 @@ def __init__( Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :paramtype max_chunk_size_in_bytes: int :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :paramtype encoding: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingStorageContainerPropertiesEncoding """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3581,136 +3367,126 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired: Twin desired properties. - :vartype desired: any + :vartype desired: JSON :ivar reported: Twin desired properties. - :vartype reported: any + :vartype reported: JSON """ _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, } - def __init__( - self, - *, - desired: Optional[Any] = None, - reported: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): """ :keyword desired: Twin desired properties. - :paramtype desired: any + :paramtype desired: JSON :keyword reported: Twin desired properties. - :paramtype reported: any + :paramtype reported: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired = desired self.reported = reported -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -3723,31 +3499,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -3756,14 +3527,14 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for file upload. @@ -3771,16 +3542,16 @@ class StorageEndpointProperties(msrest.serialization.Model): """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, } def __init__( @@ -3789,8 +3560,8 @@ def __init__( connection_string: str, container_name: str, sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, **kwargs ): """ @@ -3798,20 +3569,20 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for file upload. :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name @@ -3819,37 +3590,32 @@ def __init__( self.identity = identity -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". + "DigitalTwinChangeEvents", and "DeviceConnectionStateEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage @@ -3858,36 +3624,36 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". + "DigitalTwinChangeEvents", and "DeviceConnectionStateEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -3895,102 +3661,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2021_03_03_preview.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -3999,25 +3759,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -4035,23 +3790,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -4068,7 +3823,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2021_03_03_preview.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -4077,7 +3832,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -4089,24 +3844,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py index 3c50b0af35aa..92ca93ce8b0c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,87 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,55 +486,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateDescription", + certificate_description: Union[_models.CertificateDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: - ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription or IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -471,64 +562,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -539,55 +632,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -595,15 +690,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -612,54 +779,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,12 +853,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py index 9027f3dc07d6..85cd9bc430cf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,141 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_manual_failover_request_initial( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class IotHubOperations(object): - """IotHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _manual_failover_initial( + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") - request = build_manual_failover_request_initial( + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_03_03_preview.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> LROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -147,14 +237,18 @@ def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2021_03_03_preview.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_03_03_preview.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -165,43 +259,48 @@ def begin_manual_failover( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._manual_failover_initial( + raw_result = self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py index 73b364e5d2f0..039b902bb228 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,976 +6,842 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-03-03-preview" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -982,91 +849,110 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1079,114 +965,221 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription or + IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_03_preview.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1199,111 +1192,188 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_03_preview.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1313,91 +1383,98 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription - or ~azure.mgmt.iothub.v2021_03_03_preview.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1411,7 +1488,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1421,56 +1500,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1484,7 +1562,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1494,49 +1574,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1544,65 +1625,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1616,7 +1698,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1626,68 +1710,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1701,7 +1783,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1711,57 +1795,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1769,132 +1855,162 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore - @distributed_trace + @overload def create_event_hub_consumer_group( self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, - consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str - :param consumer_group_body: The consumer group to add. + :param consumer_group_body: The consumer group to add. Required. :type consumer_group_body: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - name=name, - content_type=content_type, - json=_json, - template_url=self.create_event_hub_consumer_group.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - - @distributed_trace - def delete_event_hub_consumer_group( + @overload + def create_event_hub_consumer_group( self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> None: - """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to add. Required. :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, + @distributed_trace + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1902,63 +2018,125 @@ def delete_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + return deserialized + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @distributed_trace + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1972,7 +2150,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1982,55 +2162,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2038,65 +2218,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2110,7 +2291,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2120,61 +2303,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2188,7 +2370,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2198,50 +2382,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] - _json = self._serialize.body(operation_inputs, 'OperationInputs') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2249,61 +2487,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. - _json = self._serialize.body(input, 'TestAllRoutesInput') + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2311,61 +2620,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] - _json = self._serialize.body(input, 'TestRouteInput') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2373,67 +2753,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2447,7 +2828,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2457,55 +2840,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2513,24 +2898,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2539,40 +2925,126 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2021_03_03_preview.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2021_03_03_preview.models.ExportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2580,24 +3052,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2606,40 +3079,126 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2021_03_03_preview.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2021_03_03_preview.models.ImportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2647,12 +3206,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py index 3b53a4a8082f..3004ce913b54 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -129,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py index 985b8c5e89fb..7b04efaad45a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,242 +6,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-03-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -248,57 +251,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,89 +312,109 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -401,114 +427,201 @@ def begin_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -522,44 +635,48 @@ def begin_delete( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py index b1dfa28d9017..2af07a62ab5f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,156 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,57 +162,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -220,12 +223,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py index 632c02b4bc72..d1caf6fba853 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-03-preview" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_03_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_03_preview.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py index eb8e4bf8ef86..c77ba0040a13 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-03-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-03-31") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-03-31" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py index 07f2dfe8d808..8f93504f469b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -41,12 +50,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_03_31.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-03-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -67,18 +79,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -87,7 +100,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_metadata.json index 6f4f713265df..a1b4e4d93cfa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py index 90a1a20ea65b..ecff387645e7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-03-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-03-31") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-03-31" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py index 26297068135e..27a0ad8d8f56 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -42,12 +51,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_03_31.aio.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-03-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -68,18 +80,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +101,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py index 2990117af7a5..afb4ef36ab3d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateDescription", + certificate_description: Union[_models.CertificateDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription or + IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py index 40b24473ac2d..89a6b8c775ee 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_operations import build_manual_failover_request_initial -T = TypeVar('T') +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubOperations: - """IotHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.aio.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _manual_failover_initial( + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_03_31.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -100,14 +200,18 @@ async def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2021_03_31.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_03_31.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -118,43 +222,48 @@ async def begin_manual_failover( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._manual_failover_initial( + raw_result = await self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py index ed5c7b17ad3b..c6e3835fd779 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +125,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +309,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +334,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_31.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +473,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_31.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +664,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription or - ~azure.mgmt.iothub.v2021_03_31.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +769,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +781,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +845,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +857,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +910,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +983,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +995,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1068,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1080,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,15 +1140,87 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_event_hub_consumer_group( @@ -898,53 +1229,73 @@ async def create_event_hub_consumer_group( resource_name: str, event_hub_endpoint_name: str, name: str, - consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str - :param consumer_group_body: The consumer group to add. + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. :type consumer_group_body: - ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription + ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_event_hub_consumer_group.metadata['url'], + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -952,61 +1303,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1017,60 +1371,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1084,7 +1438,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1094,55 +1450,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1150,65 +1508,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1222,7 +1581,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,61 +1593,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1300,7 +1660,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1310,50 +1672,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2021_03_31.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. - _json = self._serialize.body(operation_inputs, 'OperationInputs') + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2021_03_31.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1361,61 +1777,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. - _json = self._serialize.body(input, 'TestAllRoutesInput') + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1423,61 +1910,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. - _json = self._serialize.body(input, 'TestRouteInput') + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1485,67 +2043,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1559,7 +2118,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1569,55 +2130,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1625,24 +2188,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1651,39 +2215,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2021_03_31.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2021_03_31.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1691,24 +2341,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1717,39 +2368,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2021_03_31.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2021_03_31.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1757,12 +2494,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py index f4569de4cc99..061dc920f70a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py index 1ee1881b03f4..c98c9a842a39 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.aio.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,57 +105,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,89 +166,109 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -243,114 +281,201 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -364,44 +489,48 @@ async def begin_delete( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py index 3f630cd628b3..df86e0137925 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.aio.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +96,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,12 +157,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py index 43c59958ef8d..5753f39e5a1f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/__init__.py index 138c7dde883f..5bc745b7306b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/__init__.py @@ -88,132 +88,134 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - AuthenticationType, - Capabilities, - DefaultAction, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - NetworkRuleIPAction, - PrivateLinkServiceConnectionStatus, - PublicNetworkAccess, - ResourceIdentityType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import AuthenticationType +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import DefaultAction +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import NetworkRuleIPAction +from ._iot_hub_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_hub_client_enums import PublicNetworkAccess +from ._iot_hub_client_enums import ResourceIdentityType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ArmIdentity', - 'ArmUserIdentity', - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'EnrichmentProperties', - 'ErrorDetails', - 'EventHubConsumerGroupBodyDescription', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupName', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FailoverInput', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'GroupIdInformation', - 'GroupIdInformationProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubLocationDescription', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'ManagedIdentity', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'NetworkRuleSetIpRule', - 'NetworkRuleSetProperties', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionProperties', - 'PrivateLinkResources', - 'PrivateLinkServiceConnectionState', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'AuthenticationType', - 'Capabilities', - 'DefaultAction', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubReplicaRoleType', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'NetworkRuleIPAction', - 'PrivateLinkServiceConnectionStatus', - 'PublicNetworkAccess', - 'ResourceIdentityType', - 'RouteErrorSeverity', - 'RoutingSource', - 'RoutingStorageContainerPropertiesEncoding', - 'TestResultStatus', + "ArmIdentity", + "ArmUserIdentity", + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupBodyDescription", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupName", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "GroupIdInformation", + "GroupIdInformationProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "ManagedIdentity", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "NetworkRuleSetIpRule", + "NetworkRuleSetProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "AuthenticationType", + "Capabilities", + "DefaultAction", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "NetworkRuleIPAction", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "ResourceIdentityType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py index 9f70b1792da9..582048bfa653 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,30 +27,33 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Specifies authentication type being used for connecting to the storage account. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies authentication type being used for connecting to the storage account.""" KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Default Action for Network Rule Set - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default Action for Network Rule Set.""" DENY = "Deny" ALLOW = "Allow" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Health statuses have following meanings. The 'healthy' status shows that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an @@ -61,7 +62,7 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or - rejected from this endpoint + rejected from this endpoint. """ UNKNOWN = "unknown" @@ -70,14 +71,15 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired region and also the region where the IoT hub can failover to. @@ -86,17 +88,17 @@ class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -106,24 +108,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -132,13 +134,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -147,29 +149,30 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """IP Filter Action - """ + +class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP Filter Action.""" ALLOW = "Allow" -class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of a private endpoint connection - """ + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether requests from Public Network are allowed - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. @@ -180,16 +183,16 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -198,7 +201,8 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -207,9 +211,9 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEn AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py index 8552a0ed37ae..d8c445ef4f5f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ArmIdentity(msrest.serialization.Model): +class ArmIdentity(_serialization.Model): """ArmIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,8 +34,8 @@ class ArmIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the service. Possible values include: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + 'None' will remove any identities from the service. Known values are: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.iothub.v2021_03_31.models.ResourceIdentityType :ivar user_assigned_identities: Dictionary of :code:``. :vartype user_assigned_identities: dict[str, @@ -35,42 +43,42 @@ class ArmIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ArmUserIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{ArmUserIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ArmUserIdentity"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ArmUserIdentity"]] = None, **kwargs ): """ :keyword type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the service. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the service. Known values are: + "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.iothub.v2021_03_31.models.ResourceIdentityType :keyword user_assigned_identities: Dictionary of :code:``. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.iothub.v2021_03_31.models.ArmUserIdentity] """ - super(ArmIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class ArmUserIdentity(msrest.serialization.Model): +class ArmUserIdentity(_serialization.Model): """ArmUserIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -82,27 +90,23 @@ class ArmUserIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ArmUserIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -111,25 +115,20 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -147,31 +146,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -179,7 +173,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -187,24 +181,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -226,35 +215,30 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -264,7 +248,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -289,34 +273,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -327,7 +307,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -336,25 +316,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -373,32 +348,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -406,7 +376,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -422,13 +392,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -436,7 +406,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -451,13 +421,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2021_03_31.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. @@ -470,8 +440,8 @@ class EndpointHealthData(msrest.serialization.Model): accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered - to or rejected from this endpoint. Possible values include: "unknown", "healthy", "degraded", - "unhealthy", "dead". + to or rejected from this endpoint. Known values are: "unknown", "healthy", "degraded", + "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthStatus :ivar last_known_error: Last error obtained when a message failed to be delivered to iot hub. :vartype last_known_error: str @@ -485,19 +455,19 @@ class EndpointHealthData(msrest.serialization.Model): """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, - 'last_known_error': {'key': 'lastKnownError', 'type': 'str'}, - 'last_known_error_time': {'key': 'lastKnownErrorTime', 'type': 'rfc-1123'}, - 'last_successful_send_attempt_time': {'key': 'lastSuccessfulSendAttemptTime', 'type': 'rfc-1123'}, - 'last_send_attempt_time': {'key': 'lastSendAttemptTime', 'type': 'rfc-1123'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, + "last_known_error": {"key": "lastKnownError", "type": "str"}, + "last_known_error_time": {"key": "lastKnownErrorTime", "type": "rfc-1123"}, + "last_successful_send_attempt_time": {"key": "lastSuccessfulSendAttemptTime", "type": "rfc-1123"}, + "last_send_attempt_time": {"key": "lastSendAttemptTime", "type": "rfc-1123"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, last_known_error: Optional[str] = None, last_known_error_time: Optional[datetime.datetime] = None, last_successful_send_attempt_time: Optional[datetime.datetime] = None, @@ -515,8 +485,8 @@ def __init__( is not accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have - been delivered to or rejected from this endpoint. Possible values include: "unknown", - "healthy", "degraded", "unhealthy", "dead". + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "degraded", "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthStatus :keyword last_known_error: Last error obtained when a message failed to be delivered to iot hub. @@ -529,7 +499,7 @@ def __init__( :keyword last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. :paramtype last_send_attempt_time: ~datetime.datetime """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status self.last_known_error = last_known_error @@ -538,7 +508,7 @@ def __init__( self.last_send_attempt_time = last_send_attempt_time -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -550,79 +520,67 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EnrichmentProperties(msrest.serialization.Model): +class EnrichmentProperties(_serialization.Model): """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. All required parameters must be populated in order to send to Azure. - :ivar key: Required. The key or name for the enrichment property. + :ivar key: The key or name for the enrichment property. Required. :vartype key: str - :ivar value: Required. The value for the enrichment property. + :ivar value: The value for the enrichment property. Required. :vartype value: str - :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. :vartype endpoint_names: list[str] """ _validation = { - 'key': {'required': True}, - 'value': {'required': True}, - 'endpoint_names': {'required': True, 'min_items': 1}, + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, } _attribute_map = { - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, } - def __init__( - self, - *, - key: str, - value: str, - endpoint_names: List[str], - **kwargs - ): + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs): """ - :keyword key: Required. The key or name for the enrichment property. + :keyword key: The key or name for the enrichment property. Required. :paramtype key: str - :keyword value: Required. The value for the enrichment property. + :keyword value: The value for the enrichment property. Required. :paramtype value: str - :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. :paramtype endpoint_names: list[str] """ - super(EnrichmentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.value = value self.endpoint_names = endpoint_names -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -638,64 +596,55 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): +class EventHubConsumerGroupBodyDescription(_serialization.Model): """The EventHub consumer group. All required parameters must be populated in order to send to Azure. - :ivar properties: Required. The EventHub consumer group name. + :ivar properties: The EventHub consumer group name. Required. :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupName """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'EventHubConsumerGroupName'}, + "properties": {"key": "properties", "type": "EventHubConsumerGroupName"}, } - def __init__( - self, - *, - properties: "EventHubConsumerGroupName", - **kwargs - ): + def __init__(self, *, properties: "_models.EventHubConsumerGroupName", **kwargs): """ - :keyword properties: Required. The EventHub consumer group name. + :keyword properties: The EventHub consumer group name. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupName """ - super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -713,31 +662,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{object}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{object}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, any] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -745,38 +689,33 @@ def __init__( self.etag = None -class EventHubConsumerGroupName(msrest.serialization.Model): +class EventHubConsumerGroupName(_serialization.Model): """The EventHub consumer group name. All required parameters must be populated in order to send to Azure. - :ivar name: Required. EventHub consumer group name. + :ivar name: EventHub consumer group name. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. EventHub consumer group name. + :keyword name: EventHub consumer group name. Required. :paramtype name: str """ - super(EventHubConsumerGroupName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -788,37 +727,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -832,36 +766,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -869,21 +799,21 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool :ivar export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :vartype export_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for export devices. :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity @@ -895,18 +825,18 @@ class ExportDevicesRequest(msrest.serialization.Model): """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, - 'export_blob_name': {'key': 'exportBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'include_configurations': {'key': 'includeConfigurations', 'type': 'bool'}, - 'configurations_blob_name': {'key': 'configurationsBlobName', 'type': 'str'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, + "export_blob_name": {"key": "exportBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, } def __init__( @@ -915,24 +845,24 @@ def __init__( export_blob_container_uri: str, exclude_keys: bool, export_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, include_configurations: Optional[bool] = None, configurations_blob_name: Optional[str] = None, **kwargs ): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool :keyword export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :paramtype export_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for export devices. :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity @@ -943,7 +873,7 @@ def __init__( output blob container. This blob will contain the exported configurations for the Iot Hub. :paramtype configurations_blob_name: str """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys self.export_blob_name = export_blob_name @@ -953,38 +883,33 @@ def __init__( self.configurations_blob_name = configurations_blob_name -class FailoverInput(msrest.serialization.Model): +class FailoverInput(_serialization.Model): """Use to provide failover region when requesting manual Failover for a hub. All required parameters must be populated in order to send to Azure. - :ivar failover_region: Required. Region the hub will be failed over to. + :ivar failover_region: Region the hub will be failed over to. Required. :vartype failover_region: str """ _validation = { - 'failover_region': {'required': True}, + "failover_region": {"required": True}, } _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, + "failover_region": {"key": "failoverRegion", "type": "str"}, } - def __init__( - self, - *, - failover_region: str, - **kwargs - ): + def __init__(self, *, failover_region: str, **kwargs): """ - :keyword failover_region: Required. Region the hub will be failed over to. + :keyword failover_region: Region the hub will be failed over to. Required. :paramtype failover_region: str """ - super(FailoverInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_region = failover_region -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -992,39 +917,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -1035,22 +960,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DeviceConnectionStateEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -1058,7 +982,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -1075,13 +999,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1105,13 +1029,13 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class GroupIdInformation(msrest.serialization.Model): +class GroupIdInformation(_serialization.Model): """The group information for creating a private endpoint on an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1124,42 +1048,37 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties for a group information object. + :ivar properties: The properties for a group information object. Required. :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformationProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'GroupIdInformationProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, } - def __init__( - self, - *, - properties: "GroupIdInformationProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs): """ - :keyword properties: Required. The properties for a group information object. + :keyword properties: The properties for a group information object. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformationProperties """ - super(GroupIdInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class GroupIdInformationProperties(msrest.serialization.Model): +class GroupIdInformationProperties(_serialization.Model): """The properties for a group information object. :ivar group_id: The group id. @@ -1171,9 +1090,9 @@ class GroupIdInformationProperties(msrest.serialization.Model): """ _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, } def __init__( @@ -1192,20 +1111,20 @@ def __init__( :keyword required_zone_names: The required DNS zones for a specific group id. :paramtype required_zone_names: list[str] """ - super(GroupIdInformationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = group_id self.required_members = required_members self.required_zone_names = required_zone_names -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1213,7 +1132,7 @@ class ImportDevicesRequest(msrest.serialization.Model): :ivar output_blob_name: The blob name to use for storing the status of the import job. :vartype output_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for import devices. :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity @@ -1225,19 +1144,19 @@ class ImportDevicesRequest(msrest.serialization.Model): """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, - 'input_blob_name': {'key': 'inputBlobName', 'type': 'str'}, - 'output_blob_name': {'key': 'outputBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'include_configurations': {'key': 'includeConfigurations', 'type': 'bool'}, - 'configurations_blob_name': {'key': 'configurationsBlobName', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, + "input_blob_name": {"key": "inputBlobName", "type": "str"}, + "output_blob_name": {"key": "outputBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, } def __init__( @@ -1247,16 +1166,16 @@ def __init__( output_blob_container_uri: str, input_blob_name: Optional[str] = None, output_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, include_configurations: Optional[bool] = None, configurations_blob_name: Optional[str] = None, **kwargs ): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str :keyword input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1264,7 +1183,7 @@ def __init__( :keyword output_blob_name: The blob name to use for storing the status of the import job. :paramtype output_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for import devices. :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity @@ -1275,7 +1194,7 @@ def __init__( the provided input blob container. :paramtype configurations_blob_name: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri self.input_blob_name = input_blob_name @@ -1286,50 +1205,46 @@ def __init__( self.configurations_blob_name = configurations_blob_name -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1342,41 +1257,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1397,75 +1306,75 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo :ivar identity: The managed identities for the IotHub. :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ArmIdentity """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'identity': {'key': 'identity', 'type': 'ArmIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "identity": {"key": "identity", "type": "ArmIdentity"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, - identity: Optional["ArmIdentity"] = None, + properties: Optional["_models.IotHubProperties"] = None, + identity: Optional["_models.ArmIdentity"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo :keyword identity: The managed identities for the IotHub. :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ArmIdentity """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku self.identity = identity -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1477,51 +1386,46 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubLocationDescription(msrest.serialization.Model): +class IotHubLocationDescription(_serialization.Model): """Public representation of one of the locations where a resource is provisioned. :ivar location: The name of the Azure region. :vartype location: str :ivar role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery - (DR) paired region and also the region where the IoT hub can failover to. Possible values - include: "primary", "secondary". + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". :vartype role: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubReplicaRoleType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, **kwargs ): """ @@ -1529,57 +1433,51 @@ def __init__( :paramtype location: str :keyword role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster - recovery (DR) paired region and also the region where the IoT hub can failover to. Possible - values include: "primary", "secondary". + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". :paramtype role: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubReplicaRoleType """ - super(IotHubLocationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.role = role -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1588,8 +1486,8 @@ class IotHubProperties(msrest.serialization.Model): the IoT hub. :vartype authorization_policies: list[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] - :ivar public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.iothub.v2021_03_31.models.PublicNetworkAccess :ivar ip_filter_rules: The IP filter rules. @@ -1633,58 +1531,58 @@ class IotHubProperties(msrest.serialization.Model): :vartype cloud_to_device: ~azure.mgmt.iothub.v2021_03_31.models.CloudToDeviceProperties :ivar comments: IoT hub comments. :vartype comments: str - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2021_03_31.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubLocationDescription] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, - 'locations': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'network_rule_sets': {'key': 'networkRuleSets', 'type': 'NetworkRuleSetProperties'}, - 'min_tls_version': {'key': 'minTlsVersion', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'features': {'key': 'features', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "network_rule_sets": {"key": "networkRuleSets", "type": "NetworkRuleSetProperties"}, + "min_tls_version": {"key": "minTlsVersion", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "features": {"key": "features", "type": "str"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, } def __init__( self, *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - network_rule_sets: Optional["NetworkRuleSetProperties"] = None, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + network_rule_sets: Optional["_models.NetworkRuleSetProperties"] = None, min_tls_version: Optional[str] = None, - private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - features: Optional[Union[str, "Capabilities"]] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1692,8 +1590,8 @@ def __init__( to the IoT hub. :paramtype authorization_policies: list[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] - :keyword public_network_access: Whether requests from Public Network are allowed. Possible - values include: "Enabled", "Disabled". + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.iothub.v2021_03_31.models.PublicNetworkAccess :keyword ip_filter_rules: The IP filter rules. @@ -1731,11 +1629,11 @@ def __init__( :paramtype cloud_to_device: ~azure.mgmt.iothub.v2021_03_31.models.CloudToDeviceProperties :keyword comments: IoT hub comments. :paramtype comments: str - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2021_03_31.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.public_network_access = public_network_access self.ip_filter_rules = ip_filter_rules @@ -1756,7 +1654,7 @@ def __init__( self.locations = None -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1764,36 +1662,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1805,30 +1699,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1837,44 +1726,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2021_03_31.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2021_03_31.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1886,131 +1769,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2021_03_31.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2021_03_31.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2021,12 +1886,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2021_03_31.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2021_03_31.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -2037,34 +1902,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -2075,7 +1936,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2087,30 +1948,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ManagedIdentity(msrest.serialization.Model): +class ManagedIdentity(_serialization.Model): """The properties of the Managed identity. :ivar user_assigned_identity: The user assigned identity. @@ -2118,24 +1974,19 @@ class ManagedIdentity(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword user_assigned_identity: The user assigned identity. :paramtype user_assigned_identity: str """ - super(ManagedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -2143,24 +1994,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -2176,13 +2022,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -2205,13 +2051,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -2221,127 +2067,116 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class NetworkRuleSetIpRule(msrest.serialization.Model): +class NetworkRuleSetIpRule(_serialization.Model): """IP Rule to be applied as part of Network Rule Set. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. Name of the IP filter rule. + :ivar filter_name: Name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :ivar action: IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleIPAction - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } def __init__( - self, - *, - filter_name: str, - ip_mask: str, - action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, filter_name: str, ip_mask: str, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ - :keyword filter_name: Required. Name of the IP filter rule. + :keyword filter_name: Name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :keyword action: IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleIPAction - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(NetworkRuleSetIpRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class NetworkRuleSetProperties(msrest.serialization.Model): +class NetworkRuleSetProperties(_serialization.Model): """Network Rule Set Properties of IotHub. All required parameters must be populated in order to send to Azure. - :ivar default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". :vartype default_action: str or ~azure.mgmt.iothub.v2021_03_31.models.DefaultAction - :ivar apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. + :ivar apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied to + BuiltIn EventHub EndPoint of IotHub. Required. :vartype apply_to_built_in_event_hub_endpoint: bool - :ivar ip_rules: Required. List of IP Rules. + :ivar ip_rules: List of IP Rules. Required. :vartype ip_rules: list[~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleSetIpRule] """ _validation = { - 'apply_to_built_in_event_hub_endpoint': {'required': True}, - 'ip_rules': {'required': True}, + "apply_to_built_in_event_hub_endpoint": {"required": True}, + "ip_rules": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'apply_to_built_in_event_hub_endpoint': {'key': 'applyToBuiltInEventHubEndpoint', 'type': 'bool'}, - 'ip_rules': {'key': 'ipRules', 'type': '[NetworkRuleSetIpRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "apply_to_built_in_event_hub_endpoint": {"key": "applyToBuiltInEventHubEndpoint", "type": "bool"}, + "ip_rules": {"key": "ipRules", "type": "[NetworkRuleSetIpRule]"}, } def __init__( self, *, apply_to_built_in_event_hub_endpoint: bool, - ip_rules: List["NetworkRuleSetIpRule"], - default_action: Optional[Union[str, "DefaultAction"]] = "Deny", + ip_rules: List["_models.NetworkRuleSetIpRule"], + default_action: Union[str, "_models.DefaultAction"] = "Deny", **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". + :keyword default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". :paramtype default_action: str or ~azure.mgmt.iothub.v2021_03_31.models.DefaultAction - :keyword apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. + :keyword apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied + to BuiltIn EventHub EndPoint of IotHub. Required. :paramtype apply_to_built_in_event_hub_endpoint: bool - :keyword ip_rules: Required. List of IP Rules. + :keyword ip_rules: List of IP Rules. Required. :paramtype ip_rules: list[~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleSetIpRule] """ - super(NetworkRuleSetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint self.ip_rules = ip_rules -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2353,30 +2188,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2021_03_31.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2392,64 +2222,55 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -2461,27 +2282,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The private endpoint property of a private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2491,24 +2308,20 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class PrivateEndpointConnection(msrest.serialization.Model): +class PrivateEndpointConnection(_serialization.Model): """The private endpoint connection of an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -2521,85 +2334,83 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties of a private endpoint connection. + :ivar properties: The properties of a private endpoint connection. Required. :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnectionProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, } - def __init__( - self, - *, - properties: "PrivateEndpointConnectionProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs): """ - :keyword properties: Required. The properties of a private endpoint connection. + :keyword properties: The properties of a private endpoint connection. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnectionProperties """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class PrivateEndpointConnectionProperties(msrest.serialization.Model): +class PrivateEndpointConnectionProperties(_serialization.Model): """The properties of a private endpoint connection. All required parameters must be populated in order to send to Azure. :ivar private_endpoint: The private endpoint property of a private endpoint connection. :vartype private_endpoint: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpoint - :ivar private_link_service_connection_state: Required. The current state of a private endpoint - connection. + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionState """ _validation = { - 'private_link_service_connection_state': {'required': True}, + "private_link_service_connection_state": {"required": True}, } _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, } def __init__( self, *, - private_link_service_connection_state: "PrivateLinkServiceConnectionState", - private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, **kwargs ): """ :keyword private_endpoint: The private endpoint property of a private endpoint connection. :paramtype private_endpoint: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpoint - :keyword private_link_service_connection_state: Required. The current state of a private - endpoint connection. + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. :paramtype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state -class PrivateLinkResources(msrest.serialization.Model): +class PrivateLinkResources(_serialization.Model): """The available private link resources for an IotHub. :ivar value: The list of available private link resources for an IotHub. @@ -2607,152 +2418,143 @@ class PrivateLinkResources(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, + "value": {"key": "value", "type": "[GroupIdInformation]"}, } - def __init__( - self, - *, - value: Optional[List["GroupIdInformation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs): """ :keyword value: The list of available private link resources for an IotHub. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformation] """ - super(PrivateLinkResources, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The current state of a private endpoint connection. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionStatus - :ivar description: Required. The description for the current state of a private endpoint - connection. + :ivar description: The description for the current state of a private endpoint connection. + Required. :vartype description: str :ivar actions_required: Actions required for a private endpoint connection. :vartype actions_required: str """ _validation = { - 'status': {'required': True}, - 'description': {'required': True}, + "status": {"required": True}, + "description": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Union[str, "PrivateLinkServiceConnectionStatus"], + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], description: str, actions_required: Optional[str] = None, **kwargs ): """ - :keyword status: Required. The status of a private endpoint connection. Possible values - include: "Pending", "Approved", "Rejected", "Disconnected". + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionStatus - :keyword description: Required. The description for the current state of a private endpoint - connection. + :keyword description: The description for the current state of a private endpoint connection. + Required. :paramtype description: str :keyword actions_required: Actions required for a private endpoint connection. :paramtype actions_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -2762,29 +2564,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -2794,15 +2590,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -2811,79 +2607,79 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2891,7 +2687,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2912,19 +2708,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -2944,14 +2740,14 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2021_03_31.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. @@ -2964,15 +2760,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): :vartype endpoint_uri: str :ivar entity_path: Event hub name on the event hub namespace. :vartype entity_path: str - :ivar authentication_type: Method used to authenticate against the event hub endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :ivar identity: Managed identity properties of routing event hub endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -2981,31 +2777,31 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3019,22 +2815,22 @@ def __init__( :paramtype endpoint_uri: str :keyword entity_path: Event hub name on the event hub namespace. :paramtype entity_path: str - :keyword authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :keyword identity: Managed identity properties of routing event hub endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3046,7 +2842,7 @@ def __init__( self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -3058,9 +2854,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -3079,13 +2875,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -3108,19 +2904,19 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - 'enrichments': {'key': 'enrichments', 'type': '[EnrichmentProperties]'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, - enrichments: Optional[List["EnrichmentProperties"]] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, **kwargs ): """ @@ -3143,14 +2939,14 @@ def __init__( https://aka.ms/telemetryoneventgrid. :paramtype enrichments: list[~azure.mgmt.iothub.v2021_03_31.models.EnrichmentProperties] """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route self.enrichments = enrichments -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. @@ -3165,15 +2961,14 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus namespace. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus queue endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -3182,31 +2977,31 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3222,22 +3017,21 @@ def __init__( :keyword entity_path: Queue name on the service bus namespace. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus queue - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus queue endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3249,7 +3043,7 @@ def __init__( self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. @@ -3264,15 +3058,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus topic. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus topic endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -3281,31 +3075,31 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3321,22 +3115,22 @@ def __init__( :keyword entity_path: Queue name on the service bus topic. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus topic - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus topic endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3348,7 +3142,7 @@ def __init__( self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. @@ -3359,21 +3153,21 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): :vartype connection_string: str :ivar endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :vartype endpoint_uri: str - :ivar authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :ivar identity: Managed identity properties of routing storage endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3386,33 +3180,33 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :vartype max_chunk_size_in_bytes: int :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :vartype encoding: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingStorageContainerPropertiesEncoding """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -3420,17 +3214,17 @@ def __init__( *, name: str, container_name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, file_name_format: Optional[str] = None, batch_frequency_in_seconds: Optional[int] = None, max_chunk_size_in_bytes: Optional[int] = None, - encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): """ @@ -3440,21 +3234,21 @@ def __init__( :paramtype connection_string: str :keyword endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :paramtype endpoint_uri: str - :keyword authentication_type: Method used to authenticate against the storage endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :keyword identity: Managed identity properties of routing storage endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3467,12 +3261,12 @@ def __init__( Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :paramtype max_chunk_size_in_bytes: int :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :paramtype encoding: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingStorageContainerPropertiesEncoding """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3488,136 +3282,126 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired: Twin desired properties. - :vartype desired: any + :vartype desired: JSON :ivar reported: Twin desired properties. - :vartype reported: any + :vartype reported: JSON """ _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, } - def __init__( - self, - *, - desired: Optional[Any] = None, - reported: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): """ :keyword desired: Twin desired properties. - :paramtype desired: any + :paramtype desired: JSON :keyword reported: Twin desired properties. - :paramtype reported: any + :paramtype reported: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired = desired self.reported = reported -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2021_03_31.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2021_03_31.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -3630,31 +3414,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -3663,30 +3442,30 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for file upload. :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, } def __init__( @@ -3695,8 +3474,8 @@ def __init__( connection_string: str, container_name: str, sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, **kwargs ): """ @@ -3704,19 +3483,19 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for file upload. :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name @@ -3724,36 +3503,31 @@ def __init__( self.identity = identity -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource :ivar message: Routing message. @@ -3763,22 +3537,22 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource :keyword message: Routing message. @@ -3786,13 +3560,13 @@ def __init__( :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -3800,102 +3574,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2021_03_31.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2021_03_31.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2021_03_31.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -3903,25 +3671,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2021_03_31.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -3939,23 +3702,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -3972,7 +3735,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2021_03_31.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -3981,7 +3744,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3993,24 +3756,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py index a63605265f24..6989cd2cd265 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateDescription", + certificate_description: Union[_models.CertificateDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription or + IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py index 7a246268e179..0e3b900c0584 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,141 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_manual_failover_request_initial( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class IotHubOperations(object): - """IotHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _manual_failover_initial( + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") - request = build_manual_failover_request_initial( + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_03_31.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> LROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -147,14 +237,18 @@ def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2021_03_31.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_03_31.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -165,43 +259,48 @@ def begin_manual_failover( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._manual_failover_initial( + raw_result = self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py index a13d67f3a4d4..2d1f2948e7a3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,976 +6,842 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-03-31" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -982,76 +849,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -1060,15 +943,18 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1080,114 +966,222 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_31.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1199,111 +1193,186 @@ def begin_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_31.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1313,90 +1382,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription - or ~azure.mgmt.iothub.v2021_03_31.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1410,7 +1485,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1420,56 +1497,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1483,7 +1558,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1493,49 +1570,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1543,65 +1621,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1615,7 +1694,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1625,68 +1706,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1700,7 +1779,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1710,57 +1791,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1768,132 +1851,227 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore - @distributed_trace + @overload def create_event_hub_consumer_group( self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, - consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str - :param consumer_group_body: The consumer group to add. + :param consumer_group_body: The consumer group to add. Required. :type consumer_group_body: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - name=name, - content_type=content_type, - json=_json, - template_url=self.create_event_hub_consumer_group.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - - @distributed_trace - def delete_event_hub_consumer_group( + @overload + def create_event_hub_consumer_group( self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> None: - """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to add. Required. :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @distributed_trace + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1904,60 +2082,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1971,7 +2146,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1981,55 +2158,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2037,65 +2214,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2109,7 +2287,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2119,61 +2299,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2187,7 +2365,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2197,50 +2377,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2021_03_31.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. - _json = self._serialize.body(operation_inputs, 'OperationInputs') + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2021_03_31.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2248,61 +2482,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. - _json = self._serialize.body(input, 'TestAllRoutesInput') + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2310,61 +2615,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. - _json = self._serialize.body(input, 'TestRouteInput') + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2372,67 +2748,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2446,7 +2823,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2456,55 +2835,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2512,24 +2893,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2538,39 +2920,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2021_03_31.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2021_03_31.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2578,24 +3046,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2604,39 +3073,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2021_03_31.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2021_03_31.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_03_31.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2644,12 +3199,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py index b9655bb17722..84e5a7147597 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py index c89a3fa451e1..0f18daec6219 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,242 +6,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-31" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -248,57 +251,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,89 +312,109 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -401,114 +427,201 @@ def begin_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -522,44 +635,48 @@ def begin_delete( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py index e1cb8e6e05ae..facfb2d37c0a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,156 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,57 +162,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -220,12 +223,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py index 342b58062354..e58cfca1e65a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-03-31" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_03_31.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_03_31.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py index 73456830f012..16e7beaf5b87 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-07-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-07-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py index 2808835450c2..442671d41c51 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -41,12 +50,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_07_01.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -67,18 +79,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -87,7 +100,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_metadata.json index bfae722cc4d2..288c61e9f248 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py index 749606420966..f8644aa032b9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-07-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-07-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py index 8f17427a881d..3cd5ff05d017 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -42,12 +51,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_07_01.aio.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -68,18 +80,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +101,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py index 86d212e2ad00..360de3261ffd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateDescription", + certificate_description: Union[_models.CertificateDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription or + IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py index 09e4828d3b27..0b1a3d0d7b6f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_operations import build_manual_failover_request_initial -T = TypeVar('T') +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubOperations: - """IotHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.aio.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _manual_failover_initial( + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_07_01.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -100,14 +200,18 @@ async def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2021_07_01.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_07_01.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -118,43 +222,48 @@ async def begin_manual_failover( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._manual_failover_initial( + raw_result = await self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py index 0c0227544837..42a38202d093 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +125,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +309,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +334,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +473,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +664,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription or - ~azure.mgmt.iothub.v2021_07_01.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +769,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +781,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +845,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +857,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +910,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +983,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +995,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1068,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1080,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,15 +1140,87 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_event_hub_consumer_group( @@ -898,53 +1229,73 @@ async def create_event_hub_consumer_group( resource_name: str, event_hub_endpoint_name: str, name: str, - consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str - :param consumer_group_body: The consumer group to add. + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. :type consumer_group_body: - ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription + ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_event_hub_consumer_group.metadata['url'], + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -952,61 +1303,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1017,60 +1371,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1084,7 +1438,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1094,55 +1450,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1150,65 +1508,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1222,7 +1581,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,61 +1593,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1300,7 +1660,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1310,50 +1672,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2021_07_01.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. - _json = self._serialize.body(operation_inputs, 'OperationInputs') + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2021_07_01.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1361,61 +1777,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. - _json = self._serialize.body(input, 'TestAllRoutesInput') + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1423,61 +1910,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. - _json = self._serialize.body(input, 'TestRouteInput') + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1485,67 +2043,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1559,7 +2118,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1569,55 +2130,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1625,24 +2188,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1651,39 +2215,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2021_07_01.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2021_07_01.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1691,24 +2341,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1717,39 +2368,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2021_07_01.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2021_07_01.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1757,12 +2494,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py index 810279931319..c2fb417fccdc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py index 7bfb227702fe..2b1cc317847f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.aio.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,57 +105,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,89 +166,109 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -243,114 +281,201 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -364,44 +489,48 @@ async def begin_delete( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py index 2969ebe9ef94..1288f3669397 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.aio.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +96,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,12 +157,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py index cecb59652ea7..2848ced636aa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/__init__.py index 138c7dde883f..5bc745b7306b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/__init__.py @@ -88,132 +88,134 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - AuthenticationType, - Capabilities, - DefaultAction, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - NetworkRuleIPAction, - PrivateLinkServiceConnectionStatus, - PublicNetworkAccess, - ResourceIdentityType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import AuthenticationType +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import DefaultAction +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import NetworkRuleIPAction +from ._iot_hub_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_hub_client_enums import PublicNetworkAccess +from ._iot_hub_client_enums import ResourceIdentityType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ArmIdentity', - 'ArmUserIdentity', - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'EnrichmentProperties', - 'ErrorDetails', - 'EventHubConsumerGroupBodyDescription', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupName', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FailoverInput', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'GroupIdInformation', - 'GroupIdInformationProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubLocationDescription', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'ManagedIdentity', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'NetworkRuleSetIpRule', - 'NetworkRuleSetProperties', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionProperties', - 'PrivateLinkResources', - 'PrivateLinkServiceConnectionState', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'AuthenticationType', - 'Capabilities', - 'DefaultAction', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubReplicaRoleType', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'NetworkRuleIPAction', - 'PrivateLinkServiceConnectionStatus', - 'PublicNetworkAccess', - 'ResourceIdentityType', - 'RouteErrorSeverity', - 'RoutingSource', - 'RoutingStorageContainerPropertiesEncoding', - 'TestResultStatus', + "ArmIdentity", + "ArmUserIdentity", + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupBodyDescription", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupName", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "GroupIdInformation", + "GroupIdInformationProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "ManagedIdentity", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "NetworkRuleSetIpRule", + "NetworkRuleSetProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "AuthenticationType", + "Capabilities", + "DefaultAction", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "NetworkRuleIPAction", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "ResourceIdentityType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py index 9f70b1792da9..582048bfa653 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,30 +27,33 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Specifies authentication type being used for connecting to the storage account. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies authentication type being used for connecting to the storage account.""" KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Default Action for Network Rule Set - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default Action for Network Rule Set.""" DENY = "Deny" ALLOW = "Allow" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Health statuses have following meanings. The 'healthy' status shows that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an @@ -61,7 +62,7 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or - rejected from this endpoint + rejected from this endpoint. """ UNKNOWN = "unknown" @@ -70,14 +71,15 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired region and also the region where the IoT hub can failover to. @@ -86,17 +88,17 @@ class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -106,24 +108,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -132,13 +134,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -147,29 +149,30 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """IP Filter Action - """ + +class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP Filter Action.""" ALLOW = "Allow" -class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of a private endpoint connection - """ + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether requests from Public Network are allowed - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. @@ -180,16 +183,16 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -198,7 +201,8 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -207,9 +211,9 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEn AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py index 095997944480..1425beb4c207 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ArmIdentity(msrest.serialization.Model): +class ArmIdentity(_serialization.Model): """ArmIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,8 +34,8 @@ class ArmIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the service. Possible values include: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + 'None' will remove any identities from the service. Known values are: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.iothub.v2021_07_01.models.ResourceIdentityType :ivar user_assigned_identities: Dictionary of :code:``. :vartype user_assigned_identities: dict[str, @@ -35,42 +43,42 @@ class ArmIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ArmUserIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{ArmUserIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ArmUserIdentity"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ArmUserIdentity"]] = None, **kwargs ): """ :keyword type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the service. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the service. Known values are: + "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.iothub.v2021_07_01.models.ResourceIdentityType :keyword user_assigned_identities: Dictionary of :code:``. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.iothub.v2021_07_01.models.ArmUserIdentity] """ - super(ArmIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class ArmUserIdentity(msrest.serialization.Model): +class ArmUserIdentity(_serialization.Model): """ArmUserIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -82,27 +90,23 @@ class ArmUserIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ArmUserIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -114,17 +118,11 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, + "certificate": {"key": "certificate", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - is_verified: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, is_verified: Optional[bool] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. @@ -133,12 +131,12 @@ def __init__( proof of possession will not be required. :paramtype is_verified: bool """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate self.is_verified = is_verified -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -156,31 +154,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -188,7 +181,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -196,24 +189,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -235,37 +223,31 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - is_verified: Optional[bool] = None, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_verified: Optional[bool] = None, certificate: Optional[str] = None, **kwargs): """ :keyword is_verified: Determines whether certificate has been verified. :paramtype is_verified: bool :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -275,7 +257,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -300,34 +282,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -338,7 +316,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -347,25 +325,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -384,32 +357,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -417,7 +385,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -433,13 +401,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -447,7 +415,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -462,13 +430,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2021_07_01.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. @@ -481,8 +449,8 @@ class EndpointHealthData(msrest.serialization.Model): accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered - to or rejected from this endpoint. Possible values include: "unknown", "healthy", "degraded", - "unhealthy", "dead". + to or rejected from this endpoint. Known values are: "unknown", "healthy", "degraded", + "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthStatus :ivar last_known_error: Last error obtained when a message failed to be delivered to iot hub. :vartype last_known_error: str @@ -496,19 +464,19 @@ class EndpointHealthData(msrest.serialization.Model): """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, - 'last_known_error': {'key': 'lastKnownError', 'type': 'str'}, - 'last_known_error_time': {'key': 'lastKnownErrorTime', 'type': 'rfc-1123'}, - 'last_successful_send_attempt_time': {'key': 'lastSuccessfulSendAttemptTime', 'type': 'rfc-1123'}, - 'last_send_attempt_time': {'key': 'lastSendAttemptTime', 'type': 'rfc-1123'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, + "last_known_error": {"key": "lastKnownError", "type": "str"}, + "last_known_error_time": {"key": "lastKnownErrorTime", "type": "rfc-1123"}, + "last_successful_send_attempt_time": {"key": "lastSuccessfulSendAttemptTime", "type": "rfc-1123"}, + "last_send_attempt_time": {"key": "lastSendAttemptTime", "type": "rfc-1123"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, last_known_error: Optional[str] = None, last_known_error_time: Optional[datetime.datetime] = None, last_successful_send_attempt_time: Optional[datetime.datetime] = None, @@ -526,8 +494,8 @@ def __init__( is not accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have - been delivered to or rejected from this endpoint. Possible values include: "unknown", - "healthy", "degraded", "unhealthy", "dead". + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "degraded", "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthStatus :keyword last_known_error: Last error obtained when a message failed to be delivered to iot hub. @@ -540,7 +508,7 @@ def __init__( :keyword last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. :paramtype last_send_attempt_time: ~datetime.datetime """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status self.last_known_error = last_known_error @@ -549,7 +517,7 @@ def __init__( self.last_send_attempt_time = last_send_attempt_time -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,79 +529,67 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EnrichmentProperties(msrest.serialization.Model): +class EnrichmentProperties(_serialization.Model): """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. All required parameters must be populated in order to send to Azure. - :ivar key: Required. The key or name for the enrichment property. + :ivar key: The key or name for the enrichment property. Required. :vartype key: str - :ivar value: Required. The value for the enrichment property. + :ivar value: The value for the enrichment property. Required. :vartype value: str - :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. :vartype endpoint_names: list[str] """ _validation = { - 'key': {'required': True}, - 'value': {'required': True}, - 'endpoint_names': {'required': True, 'min_items': 1}, + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, } _attribute_map = { - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, } - def __init__( - self, - *, - key: str, - value: str, - endpoint_names: List[str], - **kwargs - ): + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs): """ - :keyword key: Required. The key or name for the enrichment property. + :keyword key: The key or name for the enrichment property. Required. :paramtype key: str - :keyword value: Required. The value for the enrichment property. + :keyword value: The value for the enrichment property. Required. :paramtype value: str - :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. :paramtype endpoint_names: list[str] """ - super(EnrichmentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.value = value self.endpoint_names = endpoint_names -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -649,64 +605,55 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): +class EventHubConsumerGroupBodyDescription(_serialization.Model): """The EventHub consumer group. All required parameters must be populated in order to send to Azure. - :ivar properties: Required. The EventHub consumer group name. + :ivar properties: The EventHub consumer group name. Required. :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupName """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'EventHubConsumerGroupName'}, + "properties": {"key": "properties", "type": "EventHubConsumerGroupName"}, } - def __init__( - self, - *, - properties: "EventHubConsumerGroupName", - **kwargs - ): + def __init__(self, *, properties: "_models.EventHubConsumerGroupName", **kwargs): """ - :keyword properties: Required. The EventHub consumer group name. + :keyword properties: The EventHub consumer group name. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupName """ - super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -724,31 +671,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{object}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{object}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, any] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -756,38 +698,33 @@ def __init__( self.etag = None -class EventHubConsumerGroupName(msrest.serialization.Model): +class EventHubConsumerGroupName(_serialization.Model): """The EventHub consumer group name. All required parameters must be populated in order to send to Azure. - :ivar name: Required. EventHub consumer group name. + :ivar name: EventHub consumer group name. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. EventHub consumer group name. + :keyword name: EventHub consumer group name. Required. :paramtype name: str """ - super(EventHubConsumerGroupName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -799,37 +736,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -843,36 +775,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -880,21 +808,21 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool :ivar export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :vartype export_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for export devices. :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity @@ -906,18 +834,18 @@ class ExportDevicesRequest(msrest.serialization.Model): """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, - 'export_blob_name': {'key': 'exportBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'include_configurations': {'key': 'includeConfigurations', 'type': 'bool'}, - 'configurations_blob_name': {'key': 'configurationsBlobName', 'type': 'str'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, + "export_blob_name": {"key": "exportBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, } def __init__( @@ -926,24 +854,24 @@ def __init__( export_blob_container_uri: str, exclude_keys: bool, export_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, include_configurations: Optional[bool] = None, configurations_blob_name: Optional[str] = None, **kwargs ): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool :keyword export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :paramtype export_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for export devices. :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity @@ -954,7 +882,7 @@ def __init__( output blob container. This blob will contain the exported configurations for the Iot Hub. :paramtype configurations_blob_name: str """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys self.export_blob_name = export_blob_name @@ -964,38 +892,33 @@ def __init__( self.configurations_blob_name = configurations_blob_name -class FailoverInput(msrest.serialization.Model): +class FailoverInput(_serialization.Model): """Use to provide failover region when requesting manual Failover for a hub. All required parameters must be populated in order to send to Azure. - :ivar failover_region: Required. Region the hub will be failed over to. + :ivar failover_region: Region the hub will be failed over to. Required. :vartype failover_region: str """ _validation = { - 'failover_region': {'required': True}, + "failover_region": {"required": True}, } _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, + "failover_region": {"key": "failoverRegion", "type": "str"}, } - def __init__( - self, - *, - failover_region: str, - **kwargs - ): + def __init__(self, *, failover_region: str, **kwargs): """ - :keyword failover_region: Required. Region the hub will be failed over to. + :keyword failover_region: Region the hub will be failed over to. Required. :paramtype failover_region: str """ - super(FailoverInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_region = failover_region -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -1003,39 +926,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -1046,22 +969,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DeviceConnectionStateEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -1069,7 +991,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -1086,13 +1008,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1116,13 +1038,13 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class GroupIdInformation(msrest.serialization.Model): +class GroupIdInformation(_serialization.Model): """The group information for creating a private endpoint on an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1135,42 +1057,37 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties for a group information object. + :ivar properties: The properties for a group information object. Required. :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformationProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'GroupIdInformationProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, } - def __init__( - self, - *, - properties: "GroupIdInformationProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs): """ - :keyword properties: Required. The properties for a group information object. + :keyword properties: The properties for a group information object. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformationProperties """ - super(GroupIdInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class GroupIdInformationProperties(msrest.serialization.Model): +class GroupIdInformationProperties(_serialization.Model): """The properties for a group information object. :ivar group_id: The group id. @@ -1182,9 +1099,9 @@ class GroupIdInformationProperties(msrest.serialization.Model): """ _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, } def __init__( @@ -1203,20 +1120,20 @@ def __init__( :keyword required_zone_names: The required DNS zones for a specific group id. :paramtype required_zone_names: list[str] """ - super(GroupIdInformationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = group_id self.required_members = required_members self.required_zone_names = required_zone_names -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1224,7 +1141,7 @@ class ImportDevicesRequest(msrest.serialization.Model): :ivar output_blob_name: The blob name to use for storing the status of the import job. :vartype output_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for import devices. :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity @@ -1236,19 +1153,19 @@ class ImportDevicesRequest(msrest.serialization.Model): """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, - 'input_blob_name': {'key': 'inputBlobName', 'type': 'str'}, - 'output_blob_name': {'key': 'outputBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'include_configurations': {'key': 'includeConfigurations', 'type': 'bool'}, - 'configurations_blob_name': {'key': 'configurationsBlobName', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, + "input_blob_name": {"key": "inputBlobName", "type": "str"}, + "output_blob_name": {"key": "outputBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, } def __init__( @@ -1258,16 +1175,16 @@ def __init__( output_blob_container_uri: str, input_blob_name: Optional[str] = None, output_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, include_configurations: Optional[bool] = None, configurations_blob_name: Optional[str] = None, **kwargs ): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str :keyword input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1275,7 +1192,7 @@ def __init__( :keyword output_blob_name: The blob name to use for storing the status of the import job. :paramtype output_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for import devices. :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity @@ -1286,7 +1203,7 @@ def __init__( the provided input blob container. :paramtype configurations_blob_name: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri self.input_blob_name = input_blob_name @@ -1297,50 +1214,46 @@ def __init__( self.configurations_blob_name = configurations_blob_name -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1353,41 +1266,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1408,75 +1315,75 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo :ivar identity: The managed identities for the IotHub. :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ArmIdentity """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'identity': {'key': 'identity', 'type': 'ArmIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "identity": {"key": "identity", "type": "ArmIdentity"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, - identity: Optional["ArmIdentity"] = None, + properties: Optional["_models.IotHubProperties"] = None, + identity: Optional["_models.ArmIdentity"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo :keyword identity: The managed identities for the IotHub. :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ArmIdentity """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku self.identity = identity -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1488,51 +1395,46 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubLocationDescription(msrest.serialization.Model): +class IotHubLocationDescription(_serialization.Model): """Public representation of one of the locations where a resource is provisioned. :ivar location: The name of the Azure region. :vartype location: str :ivar role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery - (DR) paired region and also the region where the IoT hub can failover to. Possible values - include: "primary", "secondary". + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". :vartype role: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubReplicaRoleType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, **kwargs ): """ @@ -1540,57 +1442,51 @@ def __init__( :paramtype location: str :keyword role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster - recovery (DR) paired region and also the region where the IoT hub can failover to. Possible - values include: "primary", "secondary". + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". :paramtype role: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubReplicaRoleType """ - super(IotHubLocationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.role = role -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1614,8 +1510,8 @@ class IotHubProperties(msrest.serialization.Model): :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot Hub. :vartype allowed_fqdn_list: list[str] - :ivar public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.iothub.v2021_07_01.models.PublicNetworkAccess :ivar ip_filter_rules: The IP filter rules. @@ -1659,68 +1555,68 @@ class IotHubProperties(msrest.serialization.Model): :vartype cloud_to_device: ~azure.mgmt.iothub.v2021_07_01.models.CloudToDeviceProperties :ivar comments: IoT hub comments. :vartype comments: str - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2021_07_01.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubLocationDescription] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, - 'locations': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'disable_local_auth': {'key': 'disableLocalAuth', 'type': 'bool'}, - 'disable_device_sas': {'key': 'disableDeviceSAS', 'type': 'bool'}, - 'disable_module_sas': {'key': 'disableModuleSAS', 'type': 'bool'}, - 'restrict_outbound_network_access': {'key': 'restrictOutboundNetworkAccess', 'type': 'bool'}, - 'allowed_fqdn_list': {'key': 'allowedFqdnList', 'type': '[str]'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'network_rule_sets': {'key': 'networkRuleSets', 'type': 'NetworkRuleSetProperties'}, - 'min_tls_version': {'key': 'minTlsVersion', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'features': {'key': 'features', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, - } - - def __init__( - self, - *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "disable_local_auth": {"key": "disableLocalAuth", "type": "bool"}, + "disable_device_sas": {"key": "disableDeviceSAS", "type": "bool"}, + "disable_module_sas": {"key": "disableModuleSAS", "type": "bool"}, + "restrict_outbound_network_access": {"key": "restrictOutboundNetworkAccess", "type": "bool"}, + "allowed_fqdn_list": {"key": "allowedFqdnList", "type": "[str]"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "network_rule_sets": {"key": "networkRuleSets", "type": "NetworkRuleSetProperties"}, + "min_tls_version": {"key": "minTlsVersion", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "features": {"key": "features", "type": "str"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, + } + + def __init__( + self, + *, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, disable_local_auth: Optional[bool] = None, disable_device_sas: Optional[bool] = None, disable_module_sas: Optional[bool] = None, restrict_outbound_network_access: Optional[bool] = None, allowed_fqdn_list: Optional[List[str]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - network_rule_sets: Optional["NetworkRuleSetProperties"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + network_rule_sets: Optional["_models.NetworkRuleSetProperties"] = None, min_tls_version: Optional[str] = None, - private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - features: Optional[Union[str, "Capabilities"]] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, **kwargs ): """ @@ -1743,8 +1639,8 @@ def __init__( :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot Hub. :paramtype allowed_fqdn_list: list[str] - :keyword public_network_access: Whether requests from Public Network are allowed. Possible - values include: "Enabled", "Disabled". + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.iothub.v2021_07_01.models.PublicNetworkAccess :keyword ip_filter_rules: The IP filter rules. @@ -1782,11 +1678,11 @@ def __init__( :paramtype cloud_to_device: ~azure.mgmt.iothub.v2021_07_01.models.CloudToDeviceProperties :keyword comments: IoT hub comments. :paramtype comments: str - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2021_07_01.models.Capabilities """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.disable_local_auth = disable_local_auth self.disable_device_sas = disable_device_sas @@ -1812,7 +1708,7 @@ def __init__( self.locations = None -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1820,36 +1716,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1861,30 +1753,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1893,44 +1780,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2021_07_01.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2021_07_01.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1942,131 +1823,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2021_07_01.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2021_07_01.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2077,12 +1940,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2021_07_01.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2021_07_01.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -2093,34 +1956,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -2131,7 +1990,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2143,30 +2002,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ManagedIdentity(msrest.serialization.Model): +class ManagedIdentity(_serialization.Model): """The properties of the Managed identity. :ivar user_assigned_identity: The user assigned identity. @@ -2174,24 +2028,19 @@ class ManagedIdentity(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword user_assigned_identity: The user assigned identity. :paramtype user_assigned_identity: str """ - super(ManagedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -2199,24 +2048,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -2232,13 +2076,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -2261,13 +2105,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -2277,127 +2121,116 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class NetworkRuleSetIpRule(msrest.serialization.Model): +class NetworkRuleSetIpRule(_serialization.Model): """IP Rule to be applied as part of Network Rule Set. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. Name of the IP filter rule. + :ivar filter_name: Name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :ivar action: IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleIPAction - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } def __init__( - self, - *, - filter_name: str, - ip_mask: str, - action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, filter_name: str, ip_mask: str, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ - :keyword filter_name: Required. Name of the IP filter rule. + :keyword filter_name: Name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :keyword action: IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleIPAction - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(NetworkRuleSetIpRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class NetworkRuleSetProperties(msrest.serialization.Model): +class NetworkRuleSetProperties(_serialization.Model): """Network Rule Set Properties of IotHub. All required parameters must be populated in order to send to Azure. - :ivar default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". :vartype default_action: str or ~azure.mgmt.iothub.v2021_07_01.models.DefaultAction - :ivar apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. + :ivar apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied to + BuiltIn EventHub EndPoint of IotHub. Required. :vartype apply_to_built_in_event_hub_endpoint: bool - :ivar ip_rules: Required. List of IP Rules. + :ivar ip_rules: List of IP Rules. Required. :vartype ip_rules: list[~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleSetIpRule] """ _validation = { - 'apply_to_built_in_event_hub_endpoint': {'required': True}, - 'ip_rules': {'required': True}, + "apply_to_built_in_event_hub_endpoint": {"required": True}, + "ip_rules": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'apply_to_built_in_event_hub_endpoint': {'key': 'applyToBuiltInEventHubEndpoint', 'type': 'bool'}, - 'ip_rules': {'key': 'ipRules', 'type': '[NetworkRuleSetIpRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "apply_to_built_in_event_hub_endpoint": {"key": "applyToBuiltInEventHubEndpoint", "type": "bool"}, + "ip_rules": {"key": "ipRules", "type": "[NetworkRuleSetIpRule]"}, } def __init__( self, *, apply_to_built_in_event_hub_endpoint: bool, - ip_rules: List["NetworkRuleSetIpRule"], - default_action: Optional[Union[str, "DefaultAction"]] = "Deny", + ip_rules: List["_models.NetworkRuleSetIpRule"], + default_action: Union[str, "_models.DefaultAction"] = "Deny", **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". + :keyword default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". :paramtype default_action: str or ~azure.mgmt.iothub.v2021_07_01.models.DefaultAction - :keyword apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. + :keyword apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied + to BuiltIn EventHub EndPoint of IotHub. Required. :paramtype apply_to_built_in_event_hub_endpoint: bool - :keyword ip_rules: Required. List of IP Rules. + :keyword ip_rules: List of IP Rules. Required. :paramtype ip_rules: list[~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleSetIpRule] """ - super(NetworkRuleSetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint self.ip_rules = ip_rules -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2409,30 +2242,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2021_07_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2448,64 +2276,55 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -2517,27 +2336,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The private endpoint property of a private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2547,24 +2362,20 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class PrivateEndpointConnection(msrest.serialization.Model): +class PrivateEndpointConnection(_serialization.Model): """The private endpoint connection of an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -2577,85 +2388,83 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties of a private endpoint connection. + :ivar properties: The properties of a private endpoint connection. Required. :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnectionProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, } - def __init__( - self, - *, - properties: "PrivateEndpointConnectionProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs): """ - :keyword properties: Required. The properties of a private endpoint connection. + :keyword properties: The properties of a private endpoint connection. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnectionProperties """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class PrivateEndpointConnectionProperties(msrest.serialization.Model): +class PrivateEndpointConnectionProperties(_serialization.Model): """The properties of a private endpoint connection. All required parameters must be populated in order to send to Azure. :ivar private_endpoint: The private endpoint property of a private endpoint connection. :vartype private_endpoint: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpoint - :ivar private_link_service_connection_state: Required. The current state of a private endpoint - connection. + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionState """ _validation = { - 'private_link_service_connection_state': {'required': True}, + "private_link_service_connection_state": {"required": True}, } _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, } def __init__( self, *, - private_link_service_connection_state: "PrivateLinkServiceConnectionState", - private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, **kwargs ): """ :keyword private_endpoint: The private endpoint property of a private endpoint connection. :paramtype private_endpoint: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpoint - :keyword private_link_service_connection_state: Required. The current state of a private - endpoint connection. + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. :paramtype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state -class PrivateLinkResources(msrest.serialization.Model): +class PrivateLinkResources(_serialization.Model): """The available private link resources for an IotHub. :ivar value: The list of available private link resources for an IotHub. @@ -2663,152 +2472,143 @@ class PrivateLinkResources(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, + "value": {"key": "value", "type": "[GroupIdInformation]"}, } - def __init__( - self, - *, - value: Optional[List["GroupIdInformation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs): """ :keyword value: The list of available private link resources for an IotHub. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformation] """ - super(PrivateLinkResources, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The current state of a private endpoint connection. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionStatus - :ivar description: Required. The description for the current state of a private endpoint - connection. + :ivar description: The description for the current state of a private endpoint connection. + Required. :vartype description: str :ivar actions_required: Actions required for a private endpoint connection. :vartype actions_required: str """ _validation = { - 'status': {'required': True}, - 'description': {'required': True}, + "status": {"required": True}, + "description": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Union[str, "PrivateLinkServiceConnectionStatus"], + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], description: str, actions_required: Optional[str] = None, **kwargs ): """ - :keyword status: Required. The status of a private endpoint connection. Possible values - include: "Pending", "Approved", "Rejected", "Disconnected". + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionStatus - :keyword description: Required. The description for the current state of a private endpoint - connection. + :keyword description: The description for the current state of a private endpoint connection. + Required. :paramtype description: str :keyword actions_required: Actions required for a private endpoint connection. :paramtype actions_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -2818,29 +2618,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -2850,15 +2644,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -2867,79 +2661,79 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2947,7 +2741,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2968,19 +2762,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -3000,14 +2794,14 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2021_07_01.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. @@ -3020,15 +2814,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): :vartype endpoint_uri: str :ivar entity_path: Event hub name on the event hub namespace. :vartype entity_path: str - :ivar authentication_type: Method used to authenticate against the event hub endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :ivar identity: Managed identity properties of routing event hub endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -3037,31 +2831,31 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3075,22 +2869,22 @@ def __init__( :paramtype endpoint_uri: str :keyword entity_path: Event hub name on the event hub namespace. :paramtype entity_path: str - :keyword authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :keyword identity: Managed identity properties of routing event hub endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3102,7 +2896,7 @@ def __init__( self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -3114,9 +2908,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -3135,13 +2929,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -3164,19 +2958,19 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - 'enrichments': {'key': 'enrichments', 'type': '[EnrichmentProperties]'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, - enrichments: Optional[List["EnrichmentProperties"]] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, **kwargs ): """ @@ -3199,14 +2993,14 @@ def __init__( https://aka.ms/telemetryoneventgrid. :paramtype enrichments: list[~azure.mgmt.iothub.v2021_07_01.models.EnrichmentProperties] """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route self.enrichments = enrichments -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. @@ -3221,15 +3015,14 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus namespace. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus queue endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -3238,31 +3031,31 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3278,22 +3071,21 @@ def __init__( :keyword entity_path: Queue name on the service bus namespace. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus queue - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus queue endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3305,7 +3097,7 @@ def __init__( self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. @@ -3320,15 +3112,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus topic. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus topic endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -3337,31 +3129,31 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3377,22 +3169,22 @@ def __init__( :keyword entity_path: Queue name on the service bus topic. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus topic - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus topic endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3404,7 +3196,7 @@ def __init__( self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. @@ -3415,21 +3207,21 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): :vartype connection_string: str :ivar endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :vartype endpoint_uri: str - :ivar authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :ivar identity: Managed identity properties of routing storage endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3442,33 +3234,33 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :vartype max_chunk_size_in_bytes: int :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :vartype encoding: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingStorageContainerPropertiesEncoding """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -3476,17 +3268,17 @@ def __init__( *, name: str, container_name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, file_name_format: Optional[str] = None, batch_frequency_in_seconds: Optional[int] = None, max_chunk_size_in_bytes: Optional[int] = None, - encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): """ @@ -3496,21 +3288,21 @@ def __init__( :paramtype connection_string: str :keyword endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :paramtype endpoint_uri: str - :keyword authentication_type: Method used to authenticate against the storage endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :keyword identity: Managed identity properties of routing storage endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3523,12 +3315,12 @@ def __init__( Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :paramtype max_chunk_size_in_bytes: int :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :paramtype encoding: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingStorageContainerPropertiesEncoding """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3544,136 +3336,126 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired: Twin desired properties. - :vartype desired: any + :vartype desired: JSON :ivar reported: Twin desired properties. - :vartype reported: any + :vartype reported: JSON """ _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, } - def __init__( - self, - *, - desired: Optional[Any] = None, - reported: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): """ :keyword desired: Twin desired properties. - :paramtype desired: any + :paramtype desired: JSON :keyword reported: Twin desired properties. - :paramtype reported: any + :paramtype reported: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired = desired self.reported = reported -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2021_07_01.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2021_07_01.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -3686,31 +3468,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -3719,30 +3496,30 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for file upload. :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, } def __init__( @@ -3751,8 +3528,8 @@ def __init__( connection_string: str, container_name: str, sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, **kwargs ): """ @@ -3760,19 +3537,19 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for file upload. :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name @@ -3780,36 +3557,31 @@ def __init__( self.identity = identity -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource :ivar message: Routing message. @@ -3819,22 +3591,22 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource :keyword message: Routing message. @@ -3842,13 +3614,13 @@ def __init__( :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -3856,102 +3628,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2021_07_01.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2021_07_01.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2021_07_01.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -3959,25 +3725,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2021_07_01.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -3995,23 +3756,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -4028,7 +3789,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2021_07_01.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -4037,7 +3798,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -4049,24 +3810,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py index 17c6e3a304c3..f5a3804f3049 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateDescription", + certificate_description: Union[_models.CertificateDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription or + IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py index bd2145e69f1e..666ee27e5e74 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,141 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_manual_failover_request_initial( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class IotHubOperations(object): - """IotHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _manual_failover_initial( + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") - request = build_manual_failover_request_initial( + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_07_01.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> LROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -147,14 +237,18 @@ def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2021_07_01.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_07_01.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -165,43 +259,48 @@ def begin_manual_failover( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._manual_failover_initial( + raw_result = self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py index f4cfb1ea2ee7..75ba201529c6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,976 +6,842 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-07-01" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -982,76 +849,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -1060,15 +943,18 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1080,114 +966,222 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1199,111 +1193,186 @@ def begin_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1313,90 +1382,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription - or ~azure.mgmt.iothub.v2021_07_01.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1410,7 +1485,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1420,56 +1497,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1483,7 +1558,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1493,49 +1570,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1543,65 +1621,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1615,7 +1694,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1625,68 +1706,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1700,7 +1779,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1710,57 +1791,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1768,132 +1851,227 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore - @distributed_trace + @overload def create_event_hub_consumer_group( self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, - consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str - :param consumer_group_body: The consumer group to add. + :param consumer_group_body: The consumer group to add. Required. :type consumer_group_body: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - name=name, - content_type=content_type, - json=_json, - template_url=self.create_event_hub_consumer_group.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - - @distributed_trace - def delete_event_hub_consumer_group( + @overload + def create_event_hub_consumer_group( self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> None: - """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to add. Required. :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @distributed_trace + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1904,60 +2082,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1971,7 +2146,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1981,55 +2158,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2037,65 +2214,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2109,7 +2287,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2119,61 +2299,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2187,7 +2365,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2197,50 +2377,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2021_07_01.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. - _json = self._serialize.body(operation_inputs, 'OperationInputs') + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2021_07_01.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2248,61 +2482,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. - _json = self._serialize.body(input, 'TestAllRoutesInput') + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2310,61 +2615,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. - _json = self._serialize.body(input, 'TestRouteInput') + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2372,67 +2748,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2446,7 +2823,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2456,55 +2835,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2512,24 +2893,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2538,39 +2920,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2021_07_01.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2021_07_01.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2578,24 +3046,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2604,39 +3073,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2021_07_01.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2021_07_01.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_01.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2644,12 +3199,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py index f537383113e7..ad3f880e1b94 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py index 2cecc8862475..5597a3a59cde 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,242 +6,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -248,57 +251,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,89 +312,109 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -401,114 +427,201 @@ def begin_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -522,44 +635,48 @@ def begin_delete( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py index b23e32727caf..113f25b4ba1b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,156 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,57 +162,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -220,12 +223,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py index 8d1262788fb2..5c18d1944879 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-01" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_01.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/__init__.py index a9adde0a702d..6b2a2a8b0d68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_configuration.py index 7aa790b27650..6e3d9202ba2d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials import TokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-07-02". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-07-02") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +45,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-07-02" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_iot_hub_client.py index 74613e0b7f83..c3f648a63f15 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models +from .._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -41,12 +50,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_07_02.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-07-02". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -67,18 +79,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -87,7 +100,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_metadata.json index fc907ed1419d..6553ac8e8ff8 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription identifier.", + "description": "The subscription identifier. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_version.py index f30401ec2040..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/__init__.py index 28356865df6a..5d9bb0b6c365 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_configuration.py index e79e5e08062c..5c86a573cc7c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_configuration.py @@ -19,25 +19,25 @@ from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration(Configuration): +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-07-02". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-07-02") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +45,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-07-02" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothub/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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') + 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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_iot_hub_client.py index 2ca594dc1cc8..6b7fb957a8e6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_iot_hub_client.py @@ -7,21 +7,30 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import IotHubClientConfiguration -from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient: + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -42,12 +51,15 @@ class IotHubClient: :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_07_02.aio.operations.PrivateEndpointConnectionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-07-02". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -68,18 +80,19 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_provider_common = ResourceProviderCommonOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +101,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_certificates_operations.py index 8e75c6f4bb47..3187cce33870 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.aio.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +105,60 @@ async def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,15 +166,86 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -162,54 +253,74 @@ async def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateDescription", + certificate_description: Union[_models.CertificateDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription or + IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,64 +329,66 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -286,55 +399,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,15 +457,87 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_07_02.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify( @@ -359,54 +546,73 @@ async def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2021_07_02.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2021_07_02.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,12 +620,11 @@ async def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_operations.py index 6a7c82f3c1b0..bd1a7788a9ae 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_operations import build_manual_failover_request_initial -T = TypeVar('T') +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubOperations: - """IotHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.aio.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _manual_failover_initial( + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_manual_failover_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_07_02.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -100,14 +200,18 @@ async def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2021_07_02.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_07_02.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -118,43 +222,48 @@ async def begin_manual_failover( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._manual_failover_initial( + raw_result = await self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_resource_operations.py index fb95b8569b74..17d64943478f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_request, build_get_endpoint_health_request, build_get_event_hub_consumer_group_request, build_get_job_request, build_get_keys_for_key_name_request, build_get_quota_metrics_request, build_get_request, build_get_stats_request, build_get_valid_skus_request, build_import_devices_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_hub_consumer_groups_request, build_list_jobs_request, build_list_keys_request, build_test_all_routes_request, build_test_route_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotHubResourceOperations: - """IotHubResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,76 +125,182 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -170,15 +309,19 @@ async def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. - :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription or IO :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -191,114 +334,133 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: "_models.TagsResource", - **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.IotHubDescription"]: + ) -> AsyncLROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_02.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -311,111 +473,188 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_02.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -425,91 +664,98 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription or - ~azure.mgmt.iothub.v2021_07_02.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -523,7 +769,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,56 +781,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) + :return: An iterator like instance of either IotHubDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -596,7 +845,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,49 +857,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace_async async def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,65 +910,66 @@ async def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,7 +983,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,68 +995,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +1068,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,57 +1080,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace_async async def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -881,15 +1140,87 @@ async def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_event_hub_consumer_group( @@ -898,53 +1229,73 @@ async def create_event_hub_consumer_group( resource_name: str, event_hub_endpoint_name: str, name: str, - consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str - :param consumer_group_body: The consumer group to add. + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. :type consumer_group_body: - ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupBodyDescription + ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_event_hub_consumer_group.metadata['url'], + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -952,61 +1303,64 @@ async def create_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace_async - async def delete_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any ) -> None: """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to delete. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1017,60 +1371,60 @@ async def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JobResponseListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) + :return: An iterator like instance of either JobResponse or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1084,7 +1438,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1094,55 +1450,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace_async async def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1150,65 +1508,66 @@ async def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1222,7 +1581,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,61 +1593,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1300,7 +1660,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1310,50 +1672,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2021_07_02.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. - _json = self._serialize.body(operation_inputs, 'OperationInputs') + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2021_07_02.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1361,61 +1777,132 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace_async + @overload async def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. - _json = self._serialize.body(input, 'TestAllRoutesInput') + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1423,61 +1910,132 @@ async def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace_async + @overload async def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. - _json = self._serialize.body(input, 'TestRouteInput') + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1485,67 +2043,68 @@ async def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1559,7 +2118,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1569,55 +2130,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace_async async def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1625,24 +2188,25 @@ async def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace_async + @overload async def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1651,39 +2215,125 @@ async def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2021_07_02.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2021_07_02.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1691,24 +2341,25 @@ async def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace_async + @overload async def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -1717,39 +2368,125 @@ async def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2021_07_02.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2021_07_02.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1757,12 +2494,11 @@ async def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_operations.py index e81caf24e1bd..36cf909a1350 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.aio.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_02.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +103,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_endpoint_connections_operations.py index 383a92b2a9e3..484c84e24149 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.aio.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,57 +105,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,89 +166,109 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -243,114 +281,201 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -364,44 +489,48 @@ async def begin_delete( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_link_resources_operations.py index 5373e65bc860..b21b5684e1b5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.aio.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,57 +96,60 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,12 +157,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_resource_provider_common_operations.py index 3ffa8304be0c..a9d048b3e195 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,74 +6,83 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceProviderCommonOperations: - """ResourceProviderCommonOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,12 +90,11 @@ async def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/__init__.py index 6210793d54ee..4741c375bd90 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/__init__.py @@ -89,135 +89,137 @@ from ._models_py3 import UserSubscriptionQuota from ._models_py3 import UserSubscriptionQuotaListResult - -from ._iot_hub_client_enums import ( - AccessRights, - AuthenticationType, - Capabilities, - CreatedByType, - DefaultAction, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - NetworkRuleIPAction, - PrivateLinkServiceConnectionStatus, - PublicNetworkAccess, - ResourceIdentityType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import AuthenticationType +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import CreatedByType +from ._iot_hub_client_enums import DefaultAction +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import NetworkRuleIPAction +from ._iot_hub_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_hub_client_enums import PublicNetworkAccess +from ._iot_hub_client_enums import ResourceIdentityType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ArmIdentity', - 'ArmUserIdentity', - 'CertificateBodyDescription', - 'CertificateDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificatePropertiesWithNonce', - 'CertificateVerificationDescription', - 'CertificateWithNonceDescription', - 'CloudToDeviceProperties', - 'EndpointHealthData', - 'EndpointHealthDataListResult', - 'EnrichmentProperties', - 'ErrorDetails', - 'EventHubConsumerGroupBodyDescription', - 'EventHubConsumerGroupInfo', - 'EventHubConsumerGroupName', - 'EventHubConsumerGroupsListResult', - 'EventHubProperties', - 'ExportDevicesRequest', - 'FailoverInput', - 'FallbackRouteProperties', - 'FeedbackProperties', - 'GroupIdInformation', - 'GroupIdInformationProperties', - 'ImportDevicesRequest', - 'IotHubCapacity', - 'IotHubDescription', - 'IotHubDescriptionListResult', - 'IotHubLocationDescription', - 'IotHubNameAvailabilityInfo', - 'IotHubProperties', - 'IotHubQuotaMetricInfo', - 'IotHubQuotaMetricInfoListResult', - 'IotHubSkuDescription', - 'IotHubSkuDescriptionListResult', - 'IotHubSkuInfo', - 'IpFilterRule', - 'JobResponse', - 'JobResponseListResult', - 'ManagedIdentity', - 'MatchedRoute', - 'MessagingEndpointProperties', - 'Name', - 'NetworkRuleSetIpRule', - 'NetworkRuleSetProperties', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionProperties', - 'PrivateLinkResources', - 'PrivateLinkServiceConnectionState', - 'RegistryStatistics', - 'Resource', - 'RouteCompilationError', - 'RouteErrorPosition', - 'RouteErrorRange', - 'RouteProperties', - 'RoutingEndpoints', - 'RoutingEventHubProperties', - 'RoutingMessage', - 'RoutingProperties', - 'RoutingServiceBusQueueEndpointProperties', - 'RoutingServiceBusTopicEndpointProperties', - 'RoutingStorageContainerProperties', - 'RoutingTwin', - 'RoutingTwinProperties', - 'SharedAccessSignatureAuthorizationRule', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'StorageEndpointProperties', - 'SystemData', - 'TagsResource', - 'TestAllRoutesInput', - 'TestAllRoutesResult', - 'TestRouteInput', - 'TestRouteResult', - 'TestRouteResultDetails', - 'UserSubscriptionQuota', - 'UserSubscriptionQuotaListResult', - 'AccessRights', - 'AuthenticationType', - 'Capabilities', - 'CreatedByType', - 'DefaultAction', - 'EndpointHealthStatus', - 'IotHubNameUnavailabilityReason', - 'IotHubReplicaRoleType', - 'IotHubScaleType', - 'IotHubSku', - 'IotHubSkuTier', - 'IpFilterActionType', - 'JobStatus', - 'JobType', - 'NetworkRuleIPAction', - 'PrivateLinkServiceConnectionStatus', - 'PublicNetworkAccess', - 'ResourceIdentityType', - 'RouteErrorSeverity', - 'RoutingSource', - 'RoutingStorageContainerPropertiesEncoding', - 'TestResultStatus', + "ArmIdentity", + "ArmUserIdentity", + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupBodyDescription", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupName", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "GroupIdInformation", + "GroupIdInformationProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "ManagedIdentity", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "NetworkRuleSetIpRule", + "NetworkRuleSetProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "SystemData", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "AuthenticationType", + "Capabilities", + "CreatedByType", + "DefaultAction", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "NetworkRuleIPAction", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "ResourceIdentityType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_iot_hub_client_enums.py index f01b6b296087..5d5a95accb2b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_iot_hub_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The permissions assigned to the shared access policy. - """ +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" REGISTRY_READ = "RegistryRead" REGISTRY_WRITE = "RegistryWrite" @@ -29,39 +27,42 @@ class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" - REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) -class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Specifies authentication type being used for connecting to the storage account. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies authentication type being used for connecting to the storage account.""" KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The capabilities and features enabled for the IoT hub. - """ + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Default Action for Network Rule Set - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default Action for Network Rule Set.""" DENY = "Deny" ALLOW = "Allow" -class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Health statuses have following meanings. The 'healthy' status shows that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an @@ -70,7 +71,7 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or - rejected from this endpoint + rejected from this endpoint. """ UNKNOWN = "unknown" @@ -79,14 +80,15 @@ class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for unavailability. - """ + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired region and also the region where the IoT hub can failover to. @@ -95,17 +97,17 @@ class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the scaling enabled. - """ + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the SKU. - """ + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" F1 = "F1" S1 = "S1" @@ -115,24 +117,24 @@ class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The billing tier for the IoT hub. - """ + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" FREE = "Free" STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" UNKNOWN = "unknown" ENQUEUED = "enqueued" @@ -141,13 +143,13 @@ class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" UNKNOWN = "unknown" EXPORT = "export" - IMPORT_ENUM = "import" + IMPORT = "import" BACKUP = "backup" READ_DEVICE_PROPERTIES = "readDeviceProperties" WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" @@ -156,29 +158,30 @@ class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """IP Filter Action - """ + +class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP Filter Action.""" ALLOW = "Allow" -class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of a private endpoint connection - """ + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether requests from Public Network are allowed - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. @@ -189,16 +192,16 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the route error - """ + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The source that the routing rule is to be applied to, such as DeviceMessages. - """ + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" INVALID = "Invalid" DEVICE_MESSAGES = "DeviceMessages" @@ -207,7 +210,8 @@ class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -216,9 +220,9 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEn AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Result of testing route - """ + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" UNDEFINED = "undefined" FALSE = "false" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_models_py3.py index 3255ed194db9..5606e99d95cd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._iot_hub_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ArmIdentity(msrest.serialization.Model): +class ArmIdentity(_serialization.Model): """ArmIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,8 +34,8 @@ class ArmIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the service. Possible values include: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + 'None' will remove any identities from the service. Known values are: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.iothub.v2021_07_02.models.ResourceIdentityType :ivar user_assigned_identities: Dictionary of :code:``. :vartype user_assigned_identities: dict[str, @@ -35,42 +43,42 @@ class ArmIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ArmUserIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{ArmUserIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ArmUserIdentity"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ArmUserIdentity"]] = None, **kwargs ): """ :keyword type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the service. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the service. Known values are: + "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.iothub.v2021_07_02.models.ResourceIdentityType :keyword user_assigned_identities: Dictionary of :code:``. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.iothub.v2021_07_02.models.ArmUserIdentity] """ - super(ArmIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class ArmUserIdentity(msrest.serialization.Model): +class ArmUserIdentity(_serialization.Model): """ArmUserIdentity. Variables are only populated by the server, and will be ignored when sending a request. @@ -82,27 +90,23 @@ class ArmUserIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ArmUserIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -114,17 +118,11 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, + "certificate": {"key": "certificate", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - is_verified: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, is_verified: Optional[bool] = None, **kwargs): """ :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. @@ -133,12 +131,12 @@ def __init__( proof of possession will not be required. :paramtype is_verified: bool """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate self.is_verified = is_verified -class CertificateDescription(msrest.serialization.Model): +class CertificateDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -156,31 +154,26 @@ class CertificateDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate. :paramtype properties: ~azure.mgmt.iothub.v2021_07_02.models.CertificateProperties """ - super(CertificateDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -188,7 +181,7 @@ def __init__( self.type = None -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -196,24 +189,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, + "value": {"key": "value", "type": "[CertificateDescription]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -235,37 +223,31 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - is_verified: Optional[bool] = None, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_verified: Optional[bool] = None, certificate: Optional[str] = None, **kwargs): """ :keyword is_verified: Determines whether certificate has been verified. :paramtype is_verified: bool :keyword certificate: The certificate content. :paramtype certificate: str """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -275,7 +257,7 @@ def __init__( self.certificate = certificate -class CertificatePropertiesWithNonce(msrest.serialization.Model): +class CertificatePropertiesWithNonce(_serialization.Model): """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. Variables are only populated by the server, and will be ignored when sending a request. @@ -300,34 +282,30 @@ class CertificatePropertiesWithNonce(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'readonly': True}, - 'certificate': {'readonly': True}, - } - - _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(CertificatePropertiesWithNonce, self).__init__(**kwargs) + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None @@ -338,7 +316,7 @@ def __init__( self.certificate = None -class CertificateVerificationDescription(msrest.serialization.Model): +class CertificateVerificationDescription(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -347,25 +325,20 @@ class CertificateVerificationDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(CertificateVerificationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class CertificateWithNonceDescription(msrest.serialization.Model): +class CertificateWithNonceDescription(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -384,32 +357,27 @@ class CertificateWithNonceDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificatePropertiesWithNonce'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["CertificatePropertiesWithNonce"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): """ :keyword properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. :paramtype properties: ~azure.mgmt.iothub.v2021_07_02.models.CertificatePropertiesWithNonce """ - super(CertificateWithNonceDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -417,7 +385,7 @@ def __init__( self.type = None -class CloudToDeviceProperties(msrest.serialization.Model): +class CloudToDeviceProperties(_serialization.Model): """The IoT hub cloud-to-device messaging properties. :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device @@ -433,13 +401,13 @@ class CloudToDeviceProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, - 'default_ttl_as_iso8601': {'key': 'defaultTtlAsIso8601', 'type': 'duration'}, - 'feedback': {'key': 'feedback', 'type': 'FeedbackProperties'}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, } def __init__( @@ -447,7 +415,7 @@ def __init__( *, max_delivery_count: Optional[int] = None, default_ttl_as_iso8601: Optional[datetime.timedelta] = None, - feedback: Optional["FeedbackProperties"] = None, + feedback: Optional["_models.FeedbackProperties"] = None, **kwargs ): """ @@ -462,13 +430,13 @@ def __init__( :keyword feedback: The properties of the feedback queue for cloud-to-device messages. :paramtype feedback: ~azure.mgmt.iothub.v2021_07_02.models.FeedbackProperties """ - super(CloudToDeviceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 self.feedback = feedback -class EndpointHealthData(msrest.serialization.Model): +class EndpointHealthData(_serialization.Model): """The health data for an endpoint. :ivar endpoint_id: Id of the endpoint. @@ -481,8 +449,8 @@ class EndpointHealthData(msrest.serialization.Model): accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have been delivered - to or rejected from this endpoint. Possible values include: "unknown", "healthy", "degraded", - "unhealthy", "dead". + to or rejected from this endpoint. Known values are: "unknown", "healthy", "degraded", + "unhealthy", and "dead". :vartype health_status: str or ~azure.mgmt.iothub.v2021_07_02.models.EndpointHealthStatus :ivar last_known_error: Last error obtained when a message failed to be delivered to iot hub. :vartype last_known_error: str @@ -496,19 +464,19 @@ class EndpointHealthData(msrest.serialization.Model): """ _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, - 'last_known_error': {'key': 'lastKnownError', 'type': 'str'}, - 'last_known_error_time': {'key': 'lastKnownErrorTime', 'type': 'rfc-1123'}, - 'last_successful_send_attempt_time': {'key': 'lastSuccessfulSendAttemptTime', 'type': 'rfc-1123'}, - 'last_send_attempt_time': {'key': 'lastSendAttemptTime', 'type': 'rfc-1123'}, + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, + "last_known_error": {"key": "lastKnownError", "type": "str"}, + "last_known_error_time": {"key": "lastKnownErrorTime", "type": "rfc-1123"}, + "last_successful_send_attempt_time": {"key": "lastSuccessfulSendAttemptTime", "type": "rfc-1123"}, + "last_send_attempt_time": {"key": "lastSendAttemptTime", "type": "rfc-1123"}, } def __init__( self, *, endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, last_known_error: Optional[str] = None, last_known_error_time: Optional[datetime.datetime] = None, last_successful_send_attempt_time: Optional[datetime.datetime] = None, @@ -526,8 +494,8 @@ def __init__( is not accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub has not established a connection with the endpoint. No messages have - been delivered to or rejected from this endpoint. Possible values include: "unknown", - "healthy", "degraded", "unhealthy", "dead". + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "degraded", "unhealthy", and "dead". :paramtype health_status: str or ~azure.mgmt.iothub.v2021_07_02.models.EndpointHealthStatus :keyword last_known_error: Last error obtained when a message failed to be delivered to iot hub. @@ -540,7 +508,7 @@ def __init__( :keyword last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. :paramtype last_send_attempt_time: ~datetime.datetime """ - super(EndpointHealthData, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status self.last_known_error = last_known_error @@ -549,7 +517,7 @@ def __init__( self.last_send_attempt_time = last_send_attempt_time -class EndpointHealthDataListResult(msrest.serialization.Model): +class EndpointHealthDataListResult(_serialization.Model): """The JSON-serialized array of EndpointHealthData objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,79 +529,67 @@ class EndpointHealthDataListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EndpointHealthData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EndpointHealthData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): """ :keyword value: JSON-serialized array of Endpoint health data. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.EndpointHealthData] """ - super(EndpointHealthDataListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EnrichmentProperties(msrest.serialization.Model): +class EnrichmentProperties(_serialization.Model): """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. All required parameters must be populated in order to send to Azure. - :ivar key: Required. The key or name for the enrichment property. + :ivar key: The key or name for the enrichment property. Required. :vartype key: str - :ivar value: Required. The value for the enrichment property. + :ivar value: The value for the enrichment property. Required. :vartype value: str - :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. :vartype endpoint_names: list[str] """ _validation = { - 'key': {'required': True}, - 'value': {'required': True}, - 'endpoint_names': {'required': True, 'min_items': 1}, + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, } _attribute_map = { - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, } - def __init__( - self, - *, - key: str, - value: str, - endpoint_names: List[str], - **kwargs - ): + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs): """ - :keyword key: Required. The key or name for the enrichment property. + :keyword key: The key or name for the enrichment property. Required. :paramtype key: str - :keyword value: Required. The value for the enrichment property. + :keyword value: The value for the enrichment property. Required. :paramtype value: str - :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. :paramtype endpoint_names: list[str] """ - super(EnrichmentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.value = value self.endpoint_names = endpoint_names -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -649,64 +605,55 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): +class EventHubConsumerGroupBodyDescription(_serialization.Model): """The EventHub consumer group. All required parameters must be populated in order to send to Azure. - :ivar properties: Required. The EventHub consumer group name. + :ivar properties: The EventHub consumer group name. Required. :vartype properties: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupName """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'EventHubConsumerGroupName'}, + "properties": {"key": "properties", "type": "EventHubConsumerGroupName"}, } - def __init__( - self, - *, - properties: "EventHubConsumerGroupName", - **kwargs - ): + def __init__(self, *, properties: "_models.EventHubConsumerGroupName", **kwargs): """ - :keyword properties: Required. The EventHub consumer group name. + :keyword properties: The EventHub consumer group name. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupName """ - super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class EventHubConsumerGroupInfo(msrest.serialization.Model): +class EventHubConsumerGroupInfo(_serialization.Model): """The properties of the EventHubConsumerGroupInfo object. Variables are only populated by the server, and will be ignored when sending a request. @@ -724,31 +671,26 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': '{object}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "properties": {"key": "properties", "type": "{object}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs): """ :keyword properties: The tags. :paramtype properties: dict[str, any] """ - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -756,38 +698,33 @@ def __init__( self.etag = None -class EventHubConsumerGroupName(msrest.serialization.Model): +class EventHubConsumerGroupName(_serialization.Model): """The EventHub consumer group name. All required parameters must be populated in order to send to Azure. - :ivar name: Required. EventHub consumer group name. + :ivar name: EventHub consumer group name. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. EventHub consumer group name. + :keyword name: EventHub consumer group name. Required. :paramtype name: str """ - super(EventHubConsumerGroupName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class EventHubConsumerGroupsListResult(msrest.serialization.Model): +class EventHubConsumerGroupsListResult(_serialization.Model): """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -799,37 +736,32 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventHubConsumerGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["EventHubConsumerGroupInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): """ :keyword value: List of consumer groups objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo] """ - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class EventHubProperties(msrest.serialization.Model): +class EventHubProperties(_serialization.Model): """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :vartype retention_time_in_days: long + :vartype retention_time_in_days: int :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. @@ -843,36 +775,32 @@ class EventHubProperties(msrest.serialization.Model): """ _validation = { - 'partition_ids': {'readonly': True}, - 'path': {'readonly': True}, - 'endpoint': {'readonly': True}, + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'retention_time_in_days': {'key': 'retentionTimeInDays', 'type': 'long'}, - 'partition_count': {'key': 'partitionCount', 'type': 'int'}, - 'partition_ids': {'key': 'partitionIds', 'type': '[str]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } def __init__( - self, - *, - retention_time_in_days: Optional[int] = None, - partition_count: Optional[int] = None, - **kwargs + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs ): """ :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. - :paramtype retention_time_in_days: long + :paramtype retention_time_in_days: int :keyword partition_count: The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. :paramtype partition_count: int """ - super(EventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count self.partition_ids = None @@ -880,21 +808,21 @@ def __init__( self.endpoint = None -class ExportDevicesRequest(msrest.serialization.Model): +class ExportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an export of all devices in the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar export_blob_container_uri: Required. The export blob container URI. + :ivar export_blob_container_uri: The export blob container URI. Required. :vartype export_blob_container_uri: str - :ivar exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. :vartype exclude_keys: bool :ivar export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :vartype export_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for export devices. :vartype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity @@ -906,18 +834,18 @@ class ExportDevicesRequest(msrest.serialization.Model): """ _validation = { - 'export_blob_container_uri': {'required': True}, - 'exclude_keys': {'required': True}, + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, } _attribute_map = { - 'export_blob_container_uri': {'key': 'exportBlobContainerUri', 'type': 'str'}, - 'exclude_keys': {'key': 'excludeKeys', 'type': 'bool'}, - 'export_blob_name': {'key': 'exportBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'include_configurations': {'key': 'includeConfigurations', 'type': 'bool'}, - 'configurations_blob_name': {'key': 'configurationsBlobName', 'type': 'str'}, + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, + "export_blob_name": {"key": "exportBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, } def __init__( @@ -926,24 +854,24 @@ def __init__( export_blob_container_uri: str, exclude_keys: bool, export_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, include_configurations: Optional[bool] = None, configurations_blob_name: Optional[str] = None, **kwargs ): """ - :keyword export_blob_container_uri: Required. The export blob container URI. + :keyword export_blob_container_uri: The export blob container URI. Required. :paramtype export_blob_container_uri: str - :keyword exclude_keys: Required. The value indicating whether keys should be excluded during - export. + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. :paramtype exclude_keys: bool :keyword export_blob_name: The name of the blob that will be created in the provided output blob container. This blob will contain the exported device registry information for the IoT Hub. :paramtype export_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for export devices. :paramtype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity @@ -954,7 +882,7 @@ def __init__( output blob container. This blob will contain the exported configurations for the Iot Hub. :paramtype configurations_blob_name: str """ - super(ExportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys self.export_blob_name = export_blob_name @@ -964,38 +892,33 @@ def __init__( self.configurations_blob_name = configurations_blob_name -class FailoverInput(msrest.serialization.Model): +class FailoverInput(_serialization.Model): """Use to provide failover region when requesting manual Failover for a hub. All required parameters must be populated in order to send to Azure. - :ivar failover_region: Required. Region the hub will be failed over to. + :ivar failover_region: Region the hub will be failed over to. Required. :vartype failover_region: str """ _validation = { - 'failover_region': {'required': True}, + "failover_region": {"required": True}, } _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, + "failover_region": {"key": "failoverRegion", "type": "str"}, } - def __init__( - self, - *, - failover_region: str, - **kwargs - ): + def __init__(self, *, failover_region: str, **kwargs): """ - :keyword failover_region: Required. Region the hub will be failed over to. + :keyword failover_region: Region the hub will be failed over to. Required. :paramtype failover_region: str """ - super(FailoverInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_region = failover_region -class FallbackRouteProperties(msrest.serialization.Model): +class FallbackRouteProperties(_serialization.Model): """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. All required parameters must be populated in order to send to Azure. @@ -1003,39 +926,39 @@ class FallbackRouteProperties(msrest.serialization.Model): :ivar name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :vartype name: str - :ivar source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype source: str or ~azure.mgmt.iothub.v2021_07_02.models.RoutingSource :ivar condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, @@ -1046,22 +969,21 @@ def __init__( :keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str - :keyword source: Required. The source to which the routing rule is to be applied to. For - example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DeviceConnectionStateEvents". + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype source: str or ~azure.mgmt.iothub.v2021_07_02.models.RoutingSource :keyword condition: The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. :paramtype is_enabled: bool """ - super(FallbackRouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -1069,7 +991,7 @@ def __init__( self.is_enabled = is_enabled -class FeedbackProperties(msrest.serialization.Model): +class FeedbackProperties(_serialization.Model): """The properties of the feedback queue for cloud-to-device messages. :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: @@ -1086,13 +1008,13 @@ class FeedbackProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -1116,13 +1038,13 @@ def __init__( https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. :paramtype max_delivery_count: int """ - super(FeedbackProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class GroupIdInformation(msrest.serialization.Model): +class GroupIdInformation(_serialization.Model): """The group information for creating a private endpoint on an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1135,42 +1057,37 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties for a group information object. + :ivar properties: The properties for a group information object. Required. :vartype properties: ~azure.mgmt.iothub.v2021_07_02.models.GroupIdInformationProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'GroupIdInformationProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, } - def __init__( - self, - *, - properties: "GroupIdInformationProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs): """ - :keyword properties: Required. The properties for a group information object. + :keyword properties: The properties for a group information object. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_07_02.models.GroupIdInformationProperties """ - super(GroupIdInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class GroupIdInformationProperties(msrest.serialization.Model): +class GroupIdInformationProperties(_serialization.Model): """The properties for a group information object. :ivar group_id: The group id. @@ -1182,9 +1099,9 @@ class GroupIdInformationProperties(msrest.serialization.Model): """ _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, } def __init__( @@ -1203,20 +1120,20 @@ def __init__( :keyword required_zone_names: The required DNS zones for a specific group id. :paramtype required_zone_names: list[str] """ - super(GroupIdInformationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = group_id self.required_members = required_members self.required_zone_names = required_zone_names -class ImportDevicesRequest(msrest.serialization.Model): +class ImportDevicesRequest(_serialization.Model): """Use to provide parameters when requesting an import of all devices in the hub. All required parameters must be populated in order to send to Azure. - :ivar input_blob_container_uri: Required. The input blob container URI. + :ivar input_blob_container_uri: The input blob container URI. Required. :vartype input_blob_container_uri: str - :ivar output_blob_container_uri: Required. The output blob container URI. + :ivar output_blob_container_uri: The output blob container URI. Required. :vartype output_blob_container_uri: str :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1224,7 +1141,7 @@ class ImportDevicesRequest(msrest.serialization.Model): :ivar output_blob_name: The blob name to use for storing the status of the import job. :vartype output_blob_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for import devices. :vartype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity @@ -1236,19 +1153,19 @@ class ImportDevicesRequest(msrest.serialization.Model): """ _validation = { - 'input_blob_container_uri': {'required': True}, - 'output_blob_container_uri': {'required': True}, + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, } _attribute_map = { - 'input_blob_container_uri': {'key': 'inputBlobContainerUri', 'type': 'str'}, - 'output_blob_container_uri': {'key': 'outputBlobContainerUri', 'type': 'str'}, - 'input_blob_name': {'key': 'inputBlobName', 'type': 'str'}, - 'output_blob_name': {'key': 'outputBlobName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'include_configurations': {'key': 'includeConfigurations', 'type': 'bool'}, - 'configurations_blob_name': {'key': 'configurationsBlobName', 'type': 'str'}, + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, + "input_blob_name": {"key": "inputBlobName", "type": "str"}, + "output_blob_name": {"key": "outputBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, } def __init__( @@ -1258,16 +1175,16 @@ def __init__( output_blob_container_uri: str, input_blob_name: Optional[str] = None, output_blob_name: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, include_configurations: Optional[bool] = None, configurations_blob_name: Optional[str] = None, **kwargs ): """ - :keyword input_blob_container_uri: Required. The input blob container URI. + :keyword input_blob_container_uri: The input blob container URI. Required. :paramtype input_blob_container_uri: str - :keyword output_blob_container_uri: Required. The output blob container URI. + :keyword output_blob_container_uri: The output blob container URI. Required. :paramtype output_blob_container_uri: str :keyword input_blob_name: The blob name to be used when importing from the provided input blob container. @@ -1275,7 +1192,7 @@ def __init__( :keyword output_blob_name: The blob name to use for storing the status of the import job. :paramtype output_blob_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for import devices. :paramtype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity @@ -1286,7 +1203,7 @@ def __init__( the provided input blob container. :paramtype configurations_blob_name: str """ - super(ImportDevicesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri self.input_blob_name = input_blob_name @@ -1297,50 +1214,46 @@ def __init__( self.configurations_blob_name = configurations_blob_name -class IotHubCapacity(msrest.serialization.Model): +class IotHubCapacity(_serialization.Model): """IoT Hub capacity information. Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum number of units. - :vartype minimum: long + :vartype minimum: int :ivar maximum: The maximum number of units. - :vartype maximum: long + :vartype maximum: int :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". :vartype scale_type: str or ~azure.mgmt.iothub.v2021_07_02.models.IotHubScaleType """ _validation = { - 'minimum': {'readonly': True, 'maximum': 1, 'minimum': 1}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1353,41 +1266,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1408,16 +1315,16 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str :ivar properties: IotHub properties. :vartype properties: ~azure.mgmt.iothub.v2021_07_02.models.IotHubProperties - :ivar sku: Required. IotHub SKU info. + :ivar sku: IotHub SKU info. Required. :vartype sku: ~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuInfo :ivar identity: The managed identities for the IotHub. :vartype identity: ~azure.mgmt.iothub.v2021_07_02.models.ArmIdentity @@ -1426,54 +1333,54 @@ class IotHubDescription(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'identity': {'key': 'identity', 'type': 'ArmIdentity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "identity": {"key": "identity", "type": "ArmIdentity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( self, *, location: str, - sku: "IotHubSkuInfo", + sku: "_models.IotHubSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, - properties: Optional["IotHubProperties"] = None, - identity: Optional["ArmIdentity"] = None, + properties: Optional["_models.IotHubProperties"] = None, + identity: Optional["_models.ArmIdentity"] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str :keyword properties: IotHub properties. :paramtype properties: ~azure.mgmt.iothub.v2021_07_02.models.IotHubProperties - :keyword sku: Required. IotHub SKU info. + :keyword sku: IotHub SKU info. Required. :paramtype sku: ~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuInfo :keyword identity: The managed identities for the IotHub. :paramtype identity: ~azure.mgmt.iothub.v2021_07_02.models.ArmIdentity """ - super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku @@ -1481,7 +1388,7 @@ def __init__( self.system_data = None -class IotHubDescriptionListResult(msrest.serialization.Model): +class IotHubDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1493,51 +1400,46 @@ class IotHubDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubDescription objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] """ - super(IotHubDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubLocationDescription(msrest.serialization.Model): +class IotHubLocationDescription(_serialization.Model): """Public representation of one of the locations where a resource is provisioned. :ivar location: The name of the Azure region. :vartype location: str :ivar role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery - (DR) paired region and also the region where the IoT hub can failover to. Possible values - include: "primary", "secondary". + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". :vartype role: str or ~azure.mgmt.iothub.v2021_07_02.models.IotHubReplicaRoleType """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, **kwargs ): """ @@ -1545,57 +1447,51 @@ def __init__( :paramtype location: str :keyword role: The role of the region, can be either primary or secondary. The primary region is where the IoT hub is currently provisioned. The secondary region is the Azure disaster - recovery (DR) paired region and also the region where the IoT hub can failover to. Possible - values include: "primary", "secondary". + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". :paramtype role: str or ~azure.mgmt.iothub.v2021_07_02.models.IotHubReplicaRoleType """ - super(IotHubLocationDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.role = role -class IotHubNameAvailabilityInfo(msrest.serialization.Model): +class IotHubNameAvailabilityInfo(_serialization.Model): """The properties indicating whether a given IoT hub name is available. Variables are only populated by the server, and will be ignored when sending a request. :ivar name_available: The value which indicates whether the provided name is available. :vartype name_available: bool - :ivar reason: The reason for unavailability. Possible values include: "Invalid", - "AlreadyExists". + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2021_07_02.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, **kwargs): """ :keyword message: The detailed reason message. :paramtype message: str """ - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = message -class IotHubProperties(msrest.serialization.Model): +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of an IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -1619,8 +1515,8 @@ class IotHubProperties(msrest.serialization.Model): :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot Hub. :vartype allowed_fqdn_list: list[str] - :ivar public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.iothub.v2021_07_02.models.PublicNetworkAccess :ivar ip_filter_rules: The IP filter rules. @@ -1664,8 +1560,8 @@ class IotHubProperties(msrest.serialization.Model): :vartype cloud_to_device: ~azure.mgmt.iothub.v2021_07_02.models.CloudToDeviceProperties :ivar comments: IoT hub comments. :vartype comments: str - :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: - "None", "DeviceManagement". + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". :vartype features: str or ~azure.mgmt.iothub.v2021_07_02.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2021_07_02.models.IotHubLocationDescription] @@ -1675,61 +1571,61 @@ class IotHubProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'readonly': True}, - 'locations': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'disable_local_auth': {'key': 'disableLocalAuth', 'type': 'bool'}, - 'disable_device_sas': {'key': 'disableDeviceSAS', 'type': 'bool'}, - 'disable_module_sas': {'key': 'disableModuleSAS', 'type': 'bool'}, - 'restrict_outbound_network_access': {'key': 'restrictOutboundNetworkAccess', 'type': 'bool'}, - 'allowed_fqdn_list': {'key': 'allowedFqdnList', 'type': '[str]'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'network_rule_sets': {'key': 'networkRuleSets', 'type': 'NetworkRuleSetProperties'}, - 'min_tls_version': {'key': 'minTlsVersion', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'features': {'key': 'features', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, - 'enable_data_residency': {'key': 'enableDataResidency', 'type': 'bool'}, - } - - def __init__( - self, - *, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "disable_local_auth": {"key": "disableLocalAuth", "type": "bool"}, + "disable_device_sas": {"key": "disableDeviceSAS", "type": "bool"}, + "disable_module_sas": {"key": "disableModuleSAS", "type": "bool"}, + "restrict_outbound_network_access": {"key": "restrictOutboundNetworkAccess", "type": "bool"}, + "allowed_fqdn_list": {"key": "allowedFqdnList", "type": "[str]"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "network_rule_sets": {"key": "networkRuleSets", "type": "NetworkRuleSetProperties"}, + "min_tls_version": {"key": "minTlsVersion", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "features": {"key": "features", "type": "str"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, + "enable_data_residency": {"key": "enableDataResidency", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, disable_local_auth: Optional[bool] = None, disable_device_sas: Optional[bool] = None, disable_module_sas: Optional[bool] = None, restrict_outbound_network_access: Optional[bool] = None, allowed_fqdn_list: Optional[List[str]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - network_rule_sets: Optional["NetworkRuleSetProperties"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + network_rule_sets: Optional["_models.NetworkRuleSetProperties"] = None, min_tls_version: Optional[str] = None, - private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, - event_hub_endpoints: Optional[Dict[str, "EventHubProperties"]] = None, - routing: Optional["RoutingProperties"] = None, - storage_endpoints: Optional[Dict[str, "StorageEndpointProperties"]] = None, - messaging_endpoints: Optional[Dict[str, "MessagingEndpointProperties"]] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, enable_file_upload_notifications: Optional[bool] = None, - cloud_to_device: Optional["CloudToDeviceProperties"] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, comments: Optional[str] = None, - features: Optional[Union[str, "Capabilities"]] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, enable_data_residency: Optional[bool] = None, **kwargs ): @@ -1753,8 +1649,8 @@ def __init__( :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot Hub. :paramtype allowed_fqdn_list: list[str] - :keyword public_network_access: Whether requests from Public Network are allowed. Possible - values include: "Enabled", "Disabled". + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.iothub.v2021_07_02.models.PublicNetworkAccess :keyword ip_filter_rules: The IP filter rules. @@ -1792,14 +1688,14 @@ def __init__( :paramtype cloud_to_device: ~azure.mgmt.iothub.v2021_07_02.models.CloudToDeviceProperties :keyword comments: IoT hub comments. :paramtype comments: str - :keyword features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". :paramtype features: str or ~azure.mgmt.iothub.v2021_07_02.models.Capabilities :keyword enable_data_residency: This property when set to true, will enable data residency, thus, disabling disaster recovery. :paramtype enable_data_residency: bool """ - super(IotHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_policies = authorization_policies self.disable_local_auth = disable_local_auth self.disable_device_sas = disable_device_sas @@ -1826,7 +1722,7 @@ def __init__( self.enable_data_residency = enable_data_residency -class IotHubQuotaMetricInfo(msrest.serialization.Model): +class IotHubQuotaMetricInfo(_serialization.Model): """Quota metrics properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1834,36 +1730,32 @@ class IotHubQuotaMetricInfo(msrest.serialization.Model): :ivar name: The name of the quota metric. :vartype name: str :ivar current_value: The current value for the quota metric. - :vartype current_value: long + :vartype current_value: int :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long + :vartype max_value: int """ _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.current_value = None self.max_value = None -class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): +class IotHubQuotaMetricInfoListResult(_serialization.Model): """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1875,30 +1767,25 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubQuotaMetricInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubQuotaMetricInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): """ :keyword value: The array of quota metrics objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.IotHubQuotaMetricInfo] """ - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuDescription(msrest.serialization.Model): +class IotHubSkuDescription(_serialization.Model): """SKU properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1907,44 +1794,38 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar sku: Required. The type of the resource. + :ivar sku: The type of the resource. Required. :vartype sku: ~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuInfo - :ivar capacity: Required. IotHub capacity. + :ivar capacity: IotHub capacity. Required. :vartype capacity: ~azure.mgmt.iothub.v2021_07_02.models.IotHubCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'required': True}, - 'capacity': {'required': True}, + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - 'capacity': {'key': 'capacity', 'type': 'IotHubCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, } - def __init__( - self, - *, - sku: "IotHubSkuInfo", - capacity: "IotHubCapacity", - **kwargs - ): + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): """ - :keyword sku: Required. The type of the resource. + :keyword sku: The type of the resource. Required. :paramtype sku: ~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuInfo - :keyword capacity: Required. IotHub capacity. + :keyword capacity: IotHub capacity. Required. :paramtype capacity: ~azure.mgmt.iothub.v2021_07_02.models.IotHubCapacity """ - super(IotHubSkuDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = None self.sku = sku self.capacity = capacity -class IotHubSkuDescriptionListResult(msrest.serialization.Model): +class IotHubSkuDescriptionListResult(_serialization.Model): """The JSON-serialized array of IotHubSkuDescription objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -1956,131 +1837,113 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotHubSkuDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotHubSkuDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): """ :keyword value: The array of IotHubSkuDescription. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuDescription] """ - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotHubSkuInfo(msrest.serialization.Model): +class IotHubSkuInfo(_serialization.Model): """Information about the SKU of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :vartype name: str or ~azure.mgmt.iothub.v2021_07_02.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuTier :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "IotHubSku"], - capacity: Optional[int] = None, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): """ - :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". :paramtype name: str or ~azure.mgmt.iothub.v2021_07_02.models.IotHubSku :keyword capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotHubSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for the IoT hub. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothub.v2021_07_02.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } - def __init__( - self, - *, - filter_name: str, - action: Union[str, "IpFilterActionType"], - ip_mask: str, - **kwargs - ): + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothub.v2021_07_02.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class JobResponse(msrest.serialization.Model): +class JobResponse(_serialization.Model): """The properties of the Job Response object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2091,12 +1954,12 @@ class JobResponse(msrest.serialization.Model): :vartype start_time_utc: ~datetime.datetime :ivar end_time_utc: The time the job stopped processing. :vartype end_time_utc: ~datetime.datetime - :ivar type: The type of the job. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". :vartype type: str or ~azure.mgmt.iothub.v2021_07_02.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". :vartype status: str or ~azure.mgmt.iothub.v2021_07_02.models.JobStatus :ivar failure_reason: If status == failed, this string containing the reason for the failure. :vartype failure_reason: str @@ -2107,34 +1970,30 @@ class JobResponse(msrest.serialization.Model): """ _validation = { - 'job_id': {'readonly': True}, - 'start_time_utc': {'readonly': True}, - 'end_time_utc': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'status_message': {'readonly': True}, - 'parent_job_id': {'readonly': True}, - } - - _attribute_map = { - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'rfc-1123'}, - 'end_time_utc': {'key': 'endTimeUtc', 'type': 'rfc-1123'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'parent_job_id': {'key': 'parentJobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(JobResponse, self).__init__(**kwargs) + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.job_id = None self.start_time_utc = None self.end_time_utc = None @@ -2145,7 +2004,7 @@ def __init__( self.parent_job_id = None -class JobResponseListResult(msrest.serialization.Model): +class JobResponseListResult(_serialization.Model): """The JSON-serialized array of JobResponse objects with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -2157,30 +2016,25 @@ class JobResponseListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[JobResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["JobResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): """ :keyword value: The array of JobResponse objects. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.JobResponse] """ - super(JobResponseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ManagedIdentity(msrest.serialization.Model): +class ManagedIdentity(_serialization.Model): """The properties of the Managed identity. :ivar user_assigned_identity: The user assigned identity. @@ -2188,24 +2042,19 @@ class ManagedIdentity(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword user_assigned_identity: The user assigned identity. :paramtype user_assigned_identity: str """ - super(ManagedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity -class MatchedRoute(msrest.serialization.Model): +class MatchedRoute(_serialization.Model): """Routes that matched. :ivar properties: Properties of routes that matched. @@ -2213,24 +2062,19 @@ class MatchedRoute(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, + "properties": {"key": "properties", "type": "RouteProperties"}, } - def __init__( - self, - *, - properties: Optional["RouteProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): """ :keyword properties: Properties of routes that matched. :paramtype properties: ~azure.mgmt.iothub.v2021_07_02.models.RouteProperties """ - super(MatchedRoute, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class MessagingEndpointProperties(msrest.serialization.Model): +class MessagingEndpointProperties(_serialization.Model): """The properties of the messaging endpoints used by this IoT hub. :ivar lock_duration_as_iso8601: The lock duration. See: @@ -2246,13 +2090,13 @@ class MessagingEndpointProperties(msrest.serialization.Model): """ _validation = { - 'max_delivery_count': {'maximum': 100, 'minimum': 1}, + "max_delivery_count": {"maximum": 100, "minimum": 1}, } _attribute_map = { - 'lock_duration_as_iso8601': {'key': 'lockDurationAsIso8601', 'type': 'duration'}, - 'ttl_as_iso8601': {'key': 'ttlAsIso8601', 'type': 'duration'}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int'}, + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, } def __init__( @@ -2275,13 +2119,13 @@ def __init__( See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. :paramtype max_delivery_count: int """ - super(MessagingEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 self.max_delivery_count = max_delivery_count -class Name(msrest.serialization.Model): +class Name(_serialization.Model): """Name of Iot Hub type. :ivar value: IotHub type. @@ -2291,127 +2135,116 @@ class Name(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: IotHub type. :paramtype value: str :keyword localized_value: Localized value of name. :paramtype localized_value: str """ - super(Name, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class NetworkRuleSetIpRule(msrest.serialization.Model): +class NetworkRuleSetIpRule(_serialization.Model): """IP Rule to be applied as part of Network Rule Set. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. Name of the IP filter rule. + :ivar filter_name: Name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :ivar action: IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.iothub.v2021_07_02.models.NetworkRuleIPAction - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str """ _validation = { - 'filter_name': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, } def __init__( - self, - *, - filter_name: str, - ip_mask: str, - action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, filter_name: str, ip_mask: str, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ - :keyword filter_name: Required. Name of the IP filter rule. + :keyword filter_name: Name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :keyword action: IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.iothub.v2021_07_02.models.NetworkRuleIPAction - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str """ - super(NetworkRuleSetIpRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask -class NetworkRuleSetProperties(msrest.serialization.Model): +class NetworkRuleSetProperties(_serialization.Model): """Network Rule Set Properties of IotHub. All required parameters must be populated in order to send to Azure. - :ivar default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". :vartype default_action: str or ~azure.mgmt.iothub.v2021_07_02.models.DefaultAction - :ivar apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. + :ivar apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied to + BuiltIn EventHub EndPoint of IotHub. Required. :vartype apply_to_built_in_event_hub_endpoint: bool - :ivar ip_rules: Required. List of IP Rules. + :ivar ip_rules: List of IP Rules. Required. :vartype ip_rules: list[~azure.mgmt.iothub.v2021_07_02.models.NetworkRuleSetIpRule] """ _validation = { - 'apply_to_built_in_event_hub_endpoint': {'required': True}, - 'ip_rules': {'required': True}, + "apply_to_built_in_event_hub_endpoint": {"required": True}, + "ip_rules": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'apply_to_built_in_event_hub_endpoint': {'key': 'applyToBuiltInEventHubEndpoint', 'type': 'bool'}, - 'ip_rules': {'key': 'ipRules', 'type': '[NetworkRuleSetIpRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "apply_to_built_in_event_hub_endpoint": {"key": "applyToBuiltInEventHubEndpoint", "type": "bool"}, + "ip_rules": {"key": "ipRules", "type": "[NetworkRuleSetIpRule]"}, } def __init__( self, *, apply_to_built_in_event_hub_endpoint: bool, - ip_rules: List["NetworkRuleSetIpRule"], - default_action: Optional[Union[str, "DefaultAction"]] = "Deny", + ip_rules: List["_models.NetworkRuleSetIpRule"], + default_action: Union[str, "_models.DefaultAction"] = "Deny", **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". + :keyword default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". :paramtype default_action: str or ~azure.mgmt.iothub.v2021_07_02.models.DefaultAction - :keyword apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. + :keyword apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied + to BuiltIn EventHub EndPoint of IotHub. Required. :paramtype apply_to_built_in_event_hub_endpoint: bool - :keyword ip_rules: Required. List of IP Rules. + :keyword ip_rules: List of IP Rules. Required. :paramtype ip_rules: list[~azure.mgmt.iothub.v2021_07_02.models.NetworkRuleSetIpRule] """ - super(NetworkRuleSetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint self.ip_rules = ip_rules -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """IoT Hub REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2423,30 +2256,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothub.v2021_07_02.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2462,64 +2290,55 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the IoT hub to check. + :ivar name: The name of the IoT hub to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the IoT hub to check. + :keyword name: The name of the IoT hub to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -2531,27 +2350,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The private endpoint property of a private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2561,24 +2376,20 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class PrivateEndpointConnection(msrest.serialization.Model): +class PrivateEndpointConnection(_serialization.Model): """The private endpoint connection of an IotHub. Variables are only populated by the server, and will be ignored when sending a request. @@ -2591,85 +2402,83 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties of a private endpoint connection. + :ivar properties: The properties of a private endpoint connection. Required. :vartype properties: ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnectionProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, } - def __init__( - self, - *, - properties: "PrivateEndpointConnectionProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs): """ - :keyword properties: Required. The properties of a private endpoint connection. + :keyword properties: The properties of a private endpoint connection. Required. :paramtype properties: ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnectionProperties """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class PrivateEndpointConnectionProperties(msrest.serialization.Model): +class PrivateEndpointConnectionProperties(_serialization.Model): """The properties of a private endpoint connection. All required parameters must be populated in order to send to Azure. :ivar private_endpoint: The private endpoint property of a private endpoint connection. :vartype private_endpoint: ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpoint - :ivar private_link_service_connection_state: Required. The current state of a private endpoint - connection. + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_07_02.models.PrivateLinkServiceConnectionState """ _validation = { - 'private_link_service_connection_state': {'required': True}, + "private_link_service_connection_state": {"required": True}, } _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, } def __init__( self, *, - private_link_service_connection_state: "PrivateLinkServiceConnectionState", - private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, **kwargs ): """ :keyword private_endpoint: The private endpoint property of a private endpoint connection. :paramtype private_endpoint: ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpoint - :keyword private_link_service_connection_state: Required. The current state of a private - endpoint connection. + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. :paramtype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_07_02.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state -class PrivateLinkResources(msrest.serialization.Model): +class PrivateLinkResources(_serialization.Model): """The available private link resources for an IotHub. :ivar value: The list of available private link resources for an IotHub. @@ -2677,152 +2486,143 @@ class PrivateLinkResources(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, + "value": {"key": "value", "type": "[GroupIdInformation]"}, } - def __init__( - self, - *, - value: Optional[List["GroupIdInformation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs): """ :keyword value: The list of available private link resources for an IotHub. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.GroupIdInformation] """ - super(PrivateLinkResources, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The current state of a private endpoint connection. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.iothub.v2021_07_02.models.PrivateLinkServiceConnectionStatus - :ivar description: Required. The description for the current state of a private endpoint - connection. + :ivar description: The description for the current state of a private endpoint connection. + Required. :vartype description: str :ivar actions_required: Actions required for a private endpoint connection. :vartype actions_required: str """ _validation = { - 'status': {'required': True}, - 'description': {'required': True}, + "status": {"required": True}, + "description": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Union[str, "PrivateLinkServiceConnectionStatus"], + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], description: str, actions_required: Optional[str] = None, **kwargs ): """ - :keyword status: Required. The status of a private endpoint connection. Possible values - include: "Pending", "Approved", "Rejected", "Disconnected". + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.iothub.v2021_07_02.models.PrivateLinkServiceConnectionStatus - :keyword description: Required. The description for the current state of a private endpoint - connection. + :keyword description: The description for the current state of a private endpoint connection. + Required. :paramtype description: str :keyword actions_required: Actions required for a private endpoint connection. :paramtype actions_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class RegistryStatistics(msrest.serialization.Model): +class RegistryStatistics(_serialization.Model): """Identity registry statistics. Variables are only populated by the server, and will be ignored when sending a request. :ivar total_device_count: The total count of devices in the identity registry. - :vartype total_device_count: long + :vartype total_device_count: int :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long + :vartype enabled_device_count: int :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long + :vartype disabled_device_count: int """ _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, } _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegistryStatistics, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None self.disabled_device_count = None -class RouteCompilationError(msrest.serialization.Model): +class RouteCompilationError(_serialization.Model): """Compilation error when evaluating route. :ivar message: Route error message. :vartype message: str - :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :ivar severity: Severity of the route error. Known values are: "error" and "warning". :vartype severity: str or ~azure.mgmt.iothub.v2021_07_02.models.RouteErrorSeverity :ivar location: Location where the route error happened. :vartype location: ~azure.mgmt.iothub.v2021_07_02.models.RouteErrorRange """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, } def __init__( self, *, message: Optional[str] = None, - severity: Optional[Union[str, "RouteErrorSeverity"]] = None, - location: Optional["RouteErrorRange"] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, **kwargs ): """ :keyword message: Route error message. :paramtype message: str - :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :keyword severity: Severity of the route error. Known values are: "error" and "warning". :paramtype severity: str or ~azure.mgmt.iothub.v2021_07_02.models.RouteErrorSeverity :keyword location: Location where the route error happened. :paramtype location: ~azure.mgmt.iothub.v2021_07_02.models.RouteErrorRange """ - super(RouteCompilationError, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.severity = severity self.location = location -class RouteErrorPosition(msrest.serialization.Model): +class RouteErrorPosition(_serialization.Model): """Position where the route error happened. :ivar line: Line where the route error happened. @@ -2832,29 +2632,23 @@ class RouteErrorPosition(msrest.serialization.Model): """ _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, } - def __init__( - self, - *, - line: Optional[int] = None, - column: Optional[int] = None, - **kwargs - ): + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): """ :keyword line: Line where the route error happened. :paramtype line: int :keyword column: Column where the route error happened. :paramtype column: int """ - super(RouteErrorPosition, self).__init__(**kwargs) + super().__init__(**kwargs) self.line = line self.column = column -class RouteErrorRange(msrest.serialization.Model): +class RouteErrorRange(_serialization.Model): """Range of route errors. :ivar start: Start where the route error happened. @@ -2864,15 +2658,15 @@ class RouteErrorRange(msrest.serialization.Model): """ _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, } def __init__( self, *, - start: Optional["RouteErrorPosition"] = None, - end: Optional["RouteErrorPosition"] = None, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, **kwargs ): """ @@ -2881,79 +2675,79 @@ def __init__( :keyword end: End where the route error happened. :paramtype end: ~azure.mgmt.iothub.v2021_07_02.models.RouteErrorPosition """ - super(RouteErrorRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start = start self.end = end -class RouteProperties(msrest.serialization.Model): +class RouteProperties(_serialization.Model): """The properties of a routing rule that your IoT hub uses to route messages to endpoints. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the route. The name can only include alphanumeric characters, - periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. :vartype name: str - :ivar source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype source: str or ~azure.mgmt.iothub.v2021_07_02.models.RoutingSource :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :vartype condition: str - :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :vartype endpoint_names: list[str] - :ivar is_enabled: Required. Used to specify whether a route is enabled. + :ivar is_enabled: Used to specify whether a route is enabled. Required. :vartype is_enabled: bool """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'condition': {'key': 'condition', 'type': 'str'}, - 'endpoint_names': {'key': 'endpointNames', 'type': '[str]'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, } def __init__( self, *, name: str, - source: Union[str, "RoutingSource"], + source: Union[str, "_models.RoutingSource"], endpoint_names: List[str], is_enabled: bool, condition: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the route. The name can only include alphanumeric - characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be - unique. + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. :paramtype name: str - :keyword source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype source: str or ~azure.mgmt.iothub.v2021_07_02.models.RoutingSource :keyword condition: The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. :paramtype condition: str - :keyword endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. :paramtype endpoint_names: list[str] - :keyword is_enabled: Required. Used to specify whether a route is enabled. + :keyword is_enabled: Used to specify whether a route is enabled. Required. :paramtype is_enabled: bool """ - super(RouteProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.source = source self.condition = condition @@ -2961,7 +2755,7 @@ def __init__( self.is_enabled = is_enabled -class RoutingEndpoints(msrest.serialization.Model): +class RoutingEndpoints(_serialization.Model): """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the @@ -2982,19 +2776,19 @@ class RoutingEndpoints(msrest.serialization.Model): """ _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - 'storage_containers': {'key': 'storageContainers', 'type': '[RoutingStorageContainerProperties]'}, + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, } def __init__( self, *, - service_bus_queues: Optional[List["RoutingServiceBusQueueEndpointProperties"]] = None, - service_bus_topics: Optional[List["RoutingServiceBusTopicEndpointProperties"]] = None, - event_hubs: Optional[List["RoutingEventHubProperties"]] = None, - storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, **kwargs ): """ @@ -3014,14 +2808,14 @@ def __init__( :paramtype storage_containers: list[~azure.mgmt.iothub.v2021_07_02.models.RoutingStorageContainerProperties] """ - super(RoutingEndpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics self.event_hubs = event_hubs self.storage_containers = storage_containers -class RoutingEventHubProperties(msrest.serialization.Model): +class RoutingEventHubProperties(_serialization.Model): """The properties related to an event hub endpoint. All required parameters must be populated in order to send to Azure. @@ -3034,15 +2828,15 @@ class RoutingEventHubProperties(msrest.serialization.Model): :vartype endpoint_uri: str :ivar entity_path: Event hub name on the event hub namespace. :vartype entity_path: str - :ivar authentication_type: Method used to authenticate against the event hub endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :ivar identity: Managed identity properties of routing event hub endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the event hub endpoint. :vartype subscription_id: str @@ -3051,31 +2845,31 @@ class RoutingEventHubProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3089,22 +2883,22 @@ def __init__( :paramtype endpoint_uri: str :keyword entity_path: Event hub name on the event hub namespace. :paramtype entity_path: str - :keyword authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :keyword identity: Managed identity properties of routing event hub endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the event hub endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the event hub endpoint. :paramtype resource_group: str """ - super(RoutingEventHubProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3116,7 +2910,7 @@ def __init__( self.resource_group = resource_group -class RoutingMessage(msrest.serialization.Model): +class RoutingMessage(_serialization.Model): """Routing message. :ivar body: Body of routing message. @@ -3128,9 +2922,9 @@ class RoutingMessage(msrest.serialization.Model): """ _attribute_map = { - 'body': {'key': 'body', 'type': 'str'}, - 'app_properties': {'key': 'appProperties', 'type': '{str}'}, - 'system_properties': {'key': 'systemProperties', 'type': '{str}'}, + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, } def __init__( @@ -3149,13 +2943,13 @@ def __init__( :keyword system_properties: System properties. :paramtype system_properties: dict[str, str] """ - super(RoutingMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.body = body self.app_properties = app_properties self.system_properties = system_properties -class RoutingProperties(msrest.serialization.Model): +class RoutingProperties(_serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes @@ -3178,19 +2972,19 @@ class RoutingProperties(msrest.serialization.Model): """ _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - 'enrichments': {'key': 'enrichments', 'type': '[EnrichmentProperties]'}, + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, } def __init__( self, *, - endpoints: Optional["RoutingEndpoints"] = None, - routes: Optional[List["RouteProperties"]] = None, - fallback_route: Optional["FallbackRouteProperties"] = None, - enrichments: Optional[List["EnrichmentProperties"]] = None, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, **kwargs ): """ @@ -3213,14 +3007,14 @@ def __init__( https://aka.ms/telemetryoneventgrid. :paramtype enrichments: list[~azure.mgmt.iothub.v2021_07_02.models.EnrichmentProperties] """ - super(RoutingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoints = endpoints self.routes = routes self.fallback_route = fallback_route self.enrichments = enrichments -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): """The properties related to service bus queue endpoint types. All required parameters must be populated in order to send to Azure. @@ -3235,15 +3029,14 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus namespace. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus queue endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus queue endpoint. :vartype subscription_id: str @@ -3252,31 +3045,31 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3292,22 +3085,21 @@ def __init__( :keyword entity_path: Queue name on the service bus namespace. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus queue - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus queue endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual queue - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus queue endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus queue endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3319,7 +3111,7 @@ def __init__( self.resource_group = resource_group -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): """The properties related to service bus topic endpoint types. All required parameters must be populated in order to send to Azure. @@ -3334,15 +3126,15 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): :ivar entity_path: Queue name on the service bus topic. :vartype entity_path: str :ivar authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". + Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus topic endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :vartype name: str :ivar subscription_id: The subscription identifier of the service bus topic endpoint. :vartype subscription_id: str @@ -3351,31 +3143,31 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'entity_path': {'key': 'entityPath', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, } def __init__( self, *, name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, entity_path: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, **kwargs @@ -3391,22 +3183,22 @@ def __init__( :keyword entity_path: Queue name on the service bus topic. :paramtype entity_path: str :keyword authentication_type: Method used to authenticate against the service bus topic - endpoint. Possible values include: "keyBased", "identityBased". + endpoint. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus topic endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. The name need not be the same as the actual topic - name. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the service bus topic endpoint. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the service bus topic endpoint. :paramtype resource_group: str """ - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3418,7 +3210,7 @@ def __init__( self.resource_group = resource_group -class RoutingStorageContainerProperties(msrest.serialization.Model): +class RoutingStorageContainerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties related to a storage container endpoint. All required parameters must be populated in order to send to Azure. @@ -3429,21 +3221,21 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): :vartype connection_string: str :ivar endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :vartype endpoint_uri: str - :ivar authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". + :ivar authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :ivar identity: Managed identity properties of routing storage endpoint. :vartype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity - :ivar name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :vartype name: str :ivar subscription_id: The subscription identifier of the storage account. :vartype subscription_id: str :ivar resource_group: The name of the resource group of the storage account. :vartype resource_group: str - :ivar container_name: Required. The name of storage container in the storage account. + :ivar container_name: The name of storage container in the storage account. Required. :vartype container_name: str :ivar file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3456,33 +3248,33 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :vartype max_chunk_size_in_bytes: int :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :vartype encoding: str or ~azure.mgmt.iothub.v2021_07_02.models.RoutingStorageContainerPropertiesEncoding """ _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, } def __init__( @@ -3490,17 +3282,17 @@ def __init__( *, name: str, container_name: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin connection_string: Optional[str] = None, endpoint_uri: Optional[str] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, subscription_id: Optional[str] = None, resource_group: Optional[str] = None, file_name_format: Optional[str] = None, batch_frequency_in_seconds: Optional[int] = None, max_chunk_size_in_bytes: Optional[int] = None, - encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): """ @@ -3510,21 +3302,21 @@ def __init__( :paramtype connection_string: str :keyword endpoint_uri: The url of the storage endpoint. It must include the protocol https://. :paramtype endpoint_uri: str - :keyword authentication_type: Method used to authenticate against the storage endpoint. - Possible values include: "keyBased", "identityBased". + :keyword authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :keyword identity: Managed identity properties of routing storage endpoint. :paramtype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity - :keyword name: Required. The name that identifies this endpoint. The name can only include - alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 - characters. The following names are reserved: events, fileNotifications, $default. Endpoint - names must be unique across endpoint types. + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. :paramtype name: str :keyword subscription_id: The subscription identifier of the storage account. :paramtype subscription_id: str :keyword resource_group: The name of the resource group of the storage account. :paramtype resource_group: str - :keyword container_name: Required. The name of storage container in the storage account. + :keyword container_name: The name of storage container in the storage account. Required. :paramtype container_name: str :keyword file_name_format: File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be @@ -3537,12 +3329,12 @@ def __init__( Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). :paramtype max_chunk_size_in_bytes: int :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". :paramtype encoding: str or ~azure.mgmt.iothub.v2021_07_02.models.RoutingStorageContainerPropertiesEncoding """ - super(RoutingStorageContainerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.connection_string = connection_string self.endpoint_uri = endpoint_uri @@ -3558,136 +3350,126 @@ def __init__( self.encoding = encoding -class RoutingTwin(msrest.serialization.Model): +class RoutingTwin(_serialization.Model): """Twin reference input parameter. This is an optional parameter. - :ivar tags: A set of tags. Twin Tags. - :vartype tags: any + :ivar tags: Twin Tags. + :vartype tags: JSON :ivar properties: :vartype properties: ~azure.mgmt.iothub.v2021_07_02.models.RoutingTwinProperties """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, } def __init__( - self, - *, - tags: Optional[Any] = None, - properties: Optional["RoutingTwinProperties"] = None, - **kwargs + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Twin Tags. - :paramtype tags: any + :keyword tags: Twin Tags. + :paramtype tags: JSON :keyword properties: :paramtype properties: ~azure.mgmt.iothub.v2021_07_02.models.RoutingTwinProperties """ - super(RoutingTwin, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.properties = properties -class RoutingTwinProperties(msrest.serialization.Model): +class RoutingTwinProperties(_serialization.Model): """RoutingTwinProperties. :ivar desired: Twin desired properties. - :vartype desired: any + :vartype desired: JSON :ivar reported: Twin desired properties. - :vartype reported: any + :vartype reported: JSON """ _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, } - def __init__( - self, - *, - desired: Optional[Any] = None, - reported: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): """ :keyword desired: Twin desired properties. - :paramtype desired: any + :paramtype desired: JSON :keyword reported: Twin desired properties. - :paramtype reported: any + :paramtype reported: JSON """ - super(RoutingTwinProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired = desired self.reported = reported -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRule(_serialization.Model): """The properties of an IoT hub shared access policy. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of the shared access policy. + :ivar key_name: The name of the shared access policy. Required. :vartype key_name: str :ivar primary_key: The primary key. :vartype primary_key: str :ivar secondary_key: The secondary key. :vartype secondary_key: str - :ivar rights: Required. The permissions assigned to the shared access policy. Possible values - include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :vartype rights: str or ~azure.mgmt.iothub.v2021_07_02.models.AccessRights """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRights"], + rights: Union[str, "_models.AccessRights"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. The name of the shared access policy. + :keyword key_name: The name of the shared access policy. Required. :paramtype key_name: str :keyword primary_key: The primary key. :paramtype primary_key: str :keyword secondary_key: The secondary key. :paramtype secondary_key: str - :keyword rights: Required. The permissions assigned to the shared access policy. Possible - values include: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", - "RegistryRead, RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", - "RegistryWrite, ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, - DeviceConnect", "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, - DeviceConnect", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". :paramtype rights: str or ~azure.mgmt.iothub.v2021_07_02.models.AccessRights """ - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """The list of shared access policies with a next link. Variables are only populated by the server, and will be ignored when sending a request. @@ -3700,31 +3482,26 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): """ :keyword value: The list of shared access policies. :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.SharedAccessSignatureAuthorizationRule] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class StorageEndpointProperties(msrest.serialization.Model): +class StorageEndpointProperties(_serialization.Model): """The properties of the Azure Storage endpoint for file upload. All required parameters must be populated in order to send to Azure. @@ -3733,30 +3510,30 @@ class StorageEndpointProperties(msrest.serialization.Model): file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :vartype sas_ttl_as_iso8601: ~datetime.timedelta - :ivar connection_string: Required. The connection string for the Azure Storage account to which - files are uploaded. + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. :vartype connection_string: str - :ivar container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. :vartype container_name: str :ivar authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for file upload. :vartype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity """ _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, + "connection_string": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, } def __init__( @@ -3765,8 +3542,8 @@ def __init__( connection_string: str, container_name: str, sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - identity: Optional["ManagedIdentity"] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, **kwargs ): """ @@ -3774,19 +3551,19 @@ def __init__( file upload is valid. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. :paramtype sas_ttl_as_iso8601: ~datetime.timedelta - :keyword connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. :paramtype connection_string: str - :keyword container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. :paramtype container_name: str :keyword authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". + storage account. Known values are: "keyBased" and "identityBased". :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_02.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for file upload. :paramtype identity: ~azure.mgmt.iothub.v2021_07_02.models.ManagedIdentity """ - super(StorageEndpointProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string self.container_name = container_name @@ -3794,62 +3571,62 @@ def __init__( self.identity = identity -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.iothub.v2021_07_02.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.iothub.v2021_07_02.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.iothub.v2021_07_02.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.iothub.v2021_07_02.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -3858,36 +3635,31 @@ def __init__( self.last_modified_at = last_modified_at -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TestAllRoutesInput(msrest.serialization.Model): +class TestAllRoutesInput(_serialization.Model): """Input for testing all routes. - :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :vartype routing_source: str or ~azure.mgmt.iothub.v2021_07_02.models.RoutingSource :ivar message: Routing message. @@ -3897,22 +3669,22 @@ class TestAllRoutesInput(msrest.serialization.Model): """ _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - routing_source: Optional[Union[str, "RoutingSource"]] = None, - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ - :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". :paramtype routing_source: str or ~azure.mgmt.iothub.v2021_07_02.models.RoutingSource :keyword message: Routing message. @@ -3920,13 +3692,13 @@ def __init__( :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2021_07_02.models.RoutingTwin """ - super(TestAllRoutesInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_source = routing_source self.message = message self.twin = twin -class TestAllRoutesResult(msrest.serialization.Model): +class TestAllRoutesResult(_serialization.Model): """Result of testing all routes. :ivar routes: JSON-serialized array of matched routes. @@ -3934,102 +3706,96 @@ class TestAllRoutesResult(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, + "routes": {"key": "routes", "type": "[MatchedRoute]"}, } - def __init__( - self, - *, - routes: Optional[List["MatchedRoute"]] = None, - **kwargs - ): + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): """ :keyword routes: JSON-serialized array of matched routes. :paramtype routes: list[~azure.mgmt.iothub.v2021_07_02.models.MatchedRoute] """ - super(TestAllRoutesResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes -class TestRouteInput(msrest.serialization.Model): +class TestRouteInput(_serialization.Model): """Input for testing route. All required parameters must be populated in order to send to Azure. :ivar message: Routing message. :vartype message: ~azure.mgmt.iothub.v2021_07_02.models.RoutingMessage - :ivar route: Required. Route properties. + :ivar route: Route properties. Required. :vartype route: ~azure.mgmt.iothub.v2021_07_02.models.RouteProperties :ivar twin: Routing Twin Reference. :vartype twin: ~azure.mgmt.iothub.v2021_07_02.models.RoutingTwin """ _validation = { - 'route': {'required': True}, + "route": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'route': {'key': 'route', 'type': 'RouteProperties'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, } def __init__( self, *, - route: "RouteProperties", - message: Optional["RoutingMessage"] = None, - twin: Optional["RoutingTwin"] = None, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, **kwargs ): """ :keyword message: Routing message. :paramtype message: ~azure.mgmt.iothub.v2021_07_02.models.RoutingMessage - :keyword route: Required. Route properties. + :keyword route: Route properties. Required. :paramtype route: ~azure.mgmt.iothub.v2021_07_02.models.RouteProperties :keyword twin: Routing Twin Reference. :paramtype twin: ~azure.mgmt.iothub.v2021_07_02.models.RoutingTwin """ - super(TestRouteInput, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.route = route self.twin = twin -class TestRouteResult(msrest.serialization.Model): +class TestRouteResult(_serialization.Model): """Result of testing one route. - :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". :vartype result: str or ~azure.mgmt.iothub.v2021_07_02.models.TestResultStatus :ivar details: Detailed result of testing route. :vartype details: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteResultDetails """ _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, } def __init__( self, *, - result: Optional[Union[str, "TestResultStatus"]] = None, - details: Optional["TestRouteResultDetails"] = None, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, **kwargs ): """ - :keyword result: Result of testing route. Possible values include: "undefined", "false", - "true". + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". :paramtype result: str or ~azure.mgmt.iothub.v2021_07_02.models.TestResultStatus :keyword details: Detailed result of testing route. :paramtype details: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteResultDetails """ - super(TestRouteResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result self.details = details -class TestRouteResultDetails(msrest.serialization.Model): +class TestRouteResultDetails(_serialization.Model): """Detailed result of testing a route. :ivar compilation_errors: JSON-serialized list of route compilation errors. @@ -4037,25 +3803,20 @@ class TestRouteResultDetails(msrest.serialization.Model): """ _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, } - def __init__( - self, - *, - compilation_errors: Optional[List["RouteCompilationError"]] = None, - **kwargs - ): + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): """ :keyword compilation_errors: JSON-serialized list of route compilation errors. :paramtype compilation_errors: list[~azure.mgmt.iothub.v2021_07_02.models.RouteCompilationError] """ - super(TestRouteResultDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.compilation_errors = compilation_errors -class UserSubscriptionQuota(msrest.serialization.Model): +class UserSubscriptionQuota(_serialization.Model): """User subscription quota response. :ivar id: IotHub type id. @@ -4073,23 +3834,23 @@ class UserSubscriptionQuota(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'Name'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["Name"] = None, + name: Optional["_models.Name"] = None, **kwargs ): """ @@ -4106,7 +3867,7 @@ def __init__( :keyword name: IotHub type. :paramtype name: ~azure.mgmt.iothub.v2021_07_02.models.Name """ - super(UserSubscriptionQuota, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.unit = unit @@ -4115,7 +3876,7 @@ def __init__( self.name = name -class UserSubscriptionQuotaListResult(msrest.serialization.Model): +class UserSubscriptionQuotaListResult(_serialization.Model): """Json-serialized array of User subscription quota response. Variables are only populated by the server, and will be ignored when sending a request. @@ -4127,24 +3888,19 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSubscriptionQuota]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSubscriptionQuota"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.iothub.v2021_07_02.models.UserSubscriptionQuota] """ - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/__init__.py index 3930a2f261c8..901e21834b4d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/__init__.py @@ -14,12 +14,18 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'IotHubResourceOperations', - 'ResourceProviderCommonOperations', - 'CertificatesOperations', - 'IotHubOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_certificates_operations.py index ae124bde9b35..5e79eafd95fd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,334 +6,330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_iot_hub_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_request( - subscription_id: str, resource_group_name: str, resource_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.IotHubClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get the certificate list. Returns the list of certificates. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_by_iot_hub_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_by_iot_hub.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,57 +337,60 @@ def list_by_iot_hub( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore - + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CertificateDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: """Get the certificate. Returns the certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,15 +398,86 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -414,54 +485,74 @@ def create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - certificate_description: "_models.CertificateDescription", + certificate_description: Union[_models.CertificateDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. + :type certificate_description: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription or + IO :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. - Required to update an existing certificate. + Required to update an existing certificate. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] - _json = self._serialize.body(certificate_description, 'CertificateDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -470,64 +561,66 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any ) -> None: """Delete an X509 certificate. Deletes an existing X509 certificate or does nothing if it does not exist. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -538,55 +631,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def generate_verification_code( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - if_match: str, - **kwargs: Any - ) -> "_models.CertificateWithNonceDescription": + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: """Generate verification code for proof of possession flow. Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateWithNonceDescription, or the result of cls(response) + :return: CertificateWithNonceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateWithNonceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateWithNonceDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] - request = build_generate_verification_code_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -594,15 +689,87 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_07_02.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify( @@ -611,54 +778,73 @@ def verify( resource_name: str, certificate_name: str, if_match: str, - certificate_verification_body: "_models.CertificateVerificationDescription", + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], **kwargs: Any - ) -> "_models.CertificateDescription": + ) -> _models.CertificateDescription: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param certificate_name: The name of the certificate. + :param certificate_name: The name of the certificate. Required. :type certificate_name: str - :param if_match: ETag of the Certificate. + :param if_match: ETag of the Certificate. Required. :type if_match: str - :param certificate_verification_body: The name of the certificate. + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2021_07_02.models.CertificateVerificationDescription + ~azure.mgmt.iothub.v2021_07_02.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateDescription, or the result of cls(response) + :return: CertificateDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.CertificateDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") request = build_verify_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.verify.metadata['url'], + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,12 +852,11 @@ def verify( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateDescription', pipeline_response) + deserialized = self._deserialize("CertificateDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore - + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_operations.py index eaaac26f205a..47a5f4711b41 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,141 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_manual_failover_request_initial( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class IotHubOperations(object): - """IotHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.IotHubClient`'s + :attr:`iot_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _manual_failover_initial( + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(failover_input, 'FailoverInput') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") - request = build_manual_failover_request_initial( + request = build_manual_failover_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._manual_failover_initial.metadata['url'], + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_07_02.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_manual_failover( self, iot_hub_name: str, resource_group_name: str, - failover_input: "_models.FailoverInput", + failover_input: Union[_models.FailoverInput, IO], **kwargs: Any ) -> LROPoller[None]: """Manually initiate a failover for the IoT Hub to its secondary region. @@ -147,14 +237,18 @@ def begin_manual_failover( Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover. - :param iot_hub_name: Name of the IoT hub to failover. + :param iot_hub_name: Name of the IoT hub to failover. Required. :type iot_hub_name: str :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. :type resource_group_name: str :param failover_input: Region to failover to. Must be the Azure paired region. Get the value from the secondary location in the locations property. To learn more, see - https://aka.ms/manualfailover/region. - :type failover_input: ~azure.mgmt.iothub.v2021_07_02.models.FailoverInput + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2021_07_02.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -165,43 +259,48 @@ def begin_manual_failover( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._manual_failover_initial( + raw_result = self._manual_failover_initial( # type: ignore iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_resource_operations.py index 963f073a91cb..50ff5dfead45 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,976 +6,842 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_stats_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_valid_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_hub_consumer_groups_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_event_hub_consumer_group_request( - subscription_id: str, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_jobs_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_job_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_quota_metrics_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_endpoint_health_request( - subscription_id: str, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-07-02" - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_all_routes_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_test_route_request( - iot_hub_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long path_format_arguments = { - "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_keys_for_key_name_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_export_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_import_devices_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class IotHubResourceOperations(object): - """IotHubResourceOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.IotHubClient`'s + :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.IotHubDescription": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubDescription, or the result of cls(response) + :return: IotHubDescription or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -982,76 +849,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: Union[_models.IotHubDescription, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_description: "_models.IotHubDescription", + iot_hub_description: _models.IotHubDescription, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to @@ -1060,15 +943,18 @@ def begin_create_or_update( updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param iot_hub_description: The IoT hub metadata and security metadata. + :param iot_hub_description: The IoT hub metadata and security metadata. Required. :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required - to update an existing IoT Hub. + to update an existing IoT Hub. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1080,114 +966,222 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - iot_hub_description=iot_hub_description, - if_match=if_match, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def _update_initial( + @distributed_trace + def begin_create_or_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IotHubDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_hub_tags, 'TagsResource') + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. - request = build_update_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, - iot_hub_tags: "_models.TagsResource", + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.IotHubDescription"]: + ) -> LROPoller[_models.IotHubDescription]: """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param resource_name: Name of iot hub to update. + :param resource_name: Name of iot hub to update. Required. :type resource_name: str - :param iot_hub_tags: Updated tag information to set into the iot hub instance. + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_02.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1199,111 +1193,186 @@ def begin_update( :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_02.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if response.status_code == 404: - deserialized = self._deserialize('ErrorDetails', pipeline_response) + deserialized = self._deserialize("ErrorDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: """Delete an IoT hub. Delete an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1313,90 +1382,96 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription - or ~azure.mgmt.iothub.v2021_07_02.models.ErrorDetails] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IotHubDescription', pipeline_response) + deserialized = self._deserialize("IotHubDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1410,7 +1485,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1420,56 +1497,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubDescriptionListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1483,7 +1558,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1493,49 +1570,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore @distributed_trace - def get_stats( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.RegistryStatistics": + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: """Get the statistics from an IoT hub. Get the statistics from an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryStatistics, or the result of cls(response) + :return: RegistryStatistics or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.RegistryStatistics - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryStatistics"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] - request = build_get_stats_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_stats.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1543,65 +1621,66 @@ def get_stats( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryStatistics', pipeline_response) + deserialized = self._deserialize("RegistryStatistics", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore - + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore @distributed_trace def get_valid_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + :return: An iterator like instance of either IotHubSkuDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_valid_skus_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1615,7 +1694,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1625,68 +1706,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore @distributed_trace def list_event_hub_consumer_groups( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - **kwargs: Any - ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, - template_url=self.list_event_hub_consumer_groups.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_hub_consumer_groups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1700,7 +1779,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1710,57 +1791,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore @distributed_trace def get_event_hub_consumer_group( - self, - resource_group_name: str, - resource_name: str, - event_hub_endpoint_name: str, - name: str, - **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to retrieve. + :param name: The name of the consumer group to retrieve. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] - request = build_get_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.get_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1768,132 +1851,227 @@ def get_event_hub_consumer_group( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore - @distributed_trace + @overload def create_event_hub_consumer_group( self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, - consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.EventHubConsumerGroupInfo": + ) -> _models.EventHubConsumerGroupInfo: """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to add. + :param name: The name of the consumer group to add. Required. :type name: str - :param consumer_group_body: The consumer group to add. + :param consumer_group_body: The consumer group to add. Required. :type consumer_group_body: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventHubConsumerGroupInfo, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - - request = build_create_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - event_hub_endpoint_name=event_hub_endpoint_name, - name=name, - content_type=content_type, - json=_json, - template_url=self.create_event_hub_consumer_group.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - - @distributed_trace - def delete_event_hub_consumer_group( + @overload + def create_event_hub_consumer_group( self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> None: - """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. :type event_hub_endpoint_name: str - :param name: The name of the consumer group to delete. + :param name: The name of the consumer group to add. Required. :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @distributed_trace + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_event_hub_consumer_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, event_hub_endpoint_name=event_hub_endpoint_name, name=name, - template_url=self.delete_event_hub_consumer_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1904,60 +2082,57 @@ def delete_event_hub_consumer_group( if cls: return cls(pipeline_response, None, {}) - delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore - + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore @distributed_trace - def list_jobs( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.JobResponseListResult"]: + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.JobResponseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_jobs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_jobs.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_jobs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1971,7 +2146,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1981,55 +2158,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore @distributed_trace - def get_job( - self, - resource_group_name: str, - resource_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.JobResponse": + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param job_id: The job identifier. + :param job_id: The job identifier. Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - request = build_get_job_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, job_id=job_id, - template_url=self.get_job.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2037,65 +2214,66 @@ def get_job( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore - + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore @distributed_trace def get_quota_metrics( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubQuotaMetricInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get_quota_metrics.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_quota_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2109,7 +2287,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2119,61 +2299,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore @distributed_trace def get_endpoint_health( - self, - resource_group_name: str, - iot_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.EndpointHealthDataListResult"]: + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. - :param resource_group_name: + :param resource_group_name: Required. :type resource_group_name: str - :param iot_hub_name: + :param iot_hub_name: Required. :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.EndpointHealthDataListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, iot_hub_name=iot_hub_name, - template_url=self.get_endpoint_health.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_get_endpoint_health_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - iot_hub_name=iot_hub_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2187,7 +2365,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2197,50 +2377,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore - @distributed_trace + @overload def check_name_availability( - self, - operation_inputs: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.IotHubNameAvailabilityInfo": + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: """Check if an IoT hub name is available. Check if an IoT hub name is available. :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of - the IoT hub to check. + the IoT hub to check. Required. :type operation_inputs: ~azure.mgmt.iothub.v2021_07_02.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IotHubNameAvailabilityInfo, or the result of cls(response) + :return: IotHubNameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.IotHubNameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubNameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. - _json = self._serialize.body(operation_inputs, 'OperationInputs') + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2021_07_02.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2248,61 +2482,132 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore - @distributed_trace + @overload def test_all_routes( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestAllRoutesInput", + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestAllRoutesResult": + ) -> _models.TestAllRoutesResult: """Test all routes. Test all routes configured in this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Input for testing all routes. + :param input: Input for testing all routes. Required. :type input: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestAllRoutesResult, or the result of cls(response) + :return: TestAllRoutesResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestAllRoutesResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. - _json = self._serialize.body(input, 'TestAllRoutesInput') + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") request = build_test_all_routes_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_all_routes.metadata['url'], + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2310,61 +2615,132 @@ def test_all_routes( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore - - @distributed_trace + @overload def test_route( self, iot_hub_name: str, resource_group_name: str, - input: "_models.TestRouteInput", + input: _models.TestRouteInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TestRouteResult": + ) -> _models.TestRouteResult: """Test the new route. Test the new route for this Iot Hub. - :param iot_hub_name: IotHub to be tested. + :param iot_hub_name: IotHub to be tested. Required. :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. + :param resource_group_name: resource group which Iot Hub belongs to. Required. :type resource_group_name: str - :param input: Route that needs to be tested. + :param input: Route that needs to be tested. Required. :type input: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestRouteResult, or the result of cls(response) + :return: TestRouteResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestRouteResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. - _json = self._serialize.body(input, 'TestRouteInput') + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") request = build_test_route_request( iot_hub_name=iot_hub_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.test_route.metadata['url'], + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2372,67 +2748,68 @@ def test_route( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestRouteResult', pipeline_response) + deserialized = self._deserialize("TestRouteResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore - + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2446,7 +2823,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2456,55 +2835,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore @distributed_trace def get_keys_for_key_name( - self, - resource_group_name: str, - resource_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRule": + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param key_name: The name of the shared access policy. + :param key_name: The name of the shared access policy. Required. :type key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response) + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.SharedAccessSignatureAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] - request = build_get_keys_for_key_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, key_name=key_name, - template_url=self.get_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2512,24 +2893,25 @@ def get_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore - + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore - @distributed_trace + @overload def export_devices( self, resource_group_name: str, resource_name: str, - export_devices_parameters: "_models.ExportDevicesRequest", + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2538,39 +2920,125 @@ def export_devices( container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. + Required. :type export_devices_parameters: ~azure.mgmt.iothub.v2021_07_02.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2021_07_02.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] - _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") request = build_export_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_devices.metadata['url'], + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2578,24 +3046,25 @@ def export_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore - + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore - @distributed_trace + @overload def import_devices( self, resource_group_name: str, resource_name: str, - import_devices_parameters: "_models.ImportDevicesRequest", + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.JobResponse": + ) -> _models.JobResponse: """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. @@ -2604,39 +3073,125 @@ def import_devices( more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. + Required. :type import_devices_parameters: ~azure.mgmt.iothub.v2021_07_02.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobResponse, or the result of cls(response) + :return: JobResponse or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. - _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2021_07_02.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2021_07_02.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") request = build_import_devices_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.import_devices.metadata['url'], + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2644,12 +3199,11 @@ def import_devices( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('JobResponse', pipeline_response) + deserialized = self._deserialize("JobResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore - + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_operations.py index 4acecf4c39b0..8e70f6ab1795 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.IotHubClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_02.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_endpoint_connections_operations.py index bb1948f499fd..b141b446d40c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,242 +6,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-07-02" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -248,57 +251,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,89 +312,109 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _update_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -401,114 +427,201 @@ def begin_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -522,44 +635,48 @@ def begin_delete( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_02.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_link_resources_operations.py index f1cfa1dc27b1..63762ae3c9c5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,156 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.IotHubClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,57 +162,60 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given IotHub. - :param resource_group_name: The name of the resource group that contains the IoT hub. + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str - :param resource_name: The name of the IoT hub. + :param resource_name: The name of the IoT hub. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -220,12 +223,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_resource_provider_common_operations.py index 95a0f5892e04..c9c4ef382645 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_resource_provider_common_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_subscription_quota_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-07-02" - accept = "application/json" + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ResourceProviderCommonOperations(object): - """ResourceProviderCommonOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothub.v2021_07_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2021_07_02.IotHubClient`'s + :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_subscription_quota( - self, - **kwargs: Any - ) -> "_models.UserSubscriptionQuotaListResult": + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: """Get the number of iot hubs in the subscription. Get the number of free and paid iot hubs in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSubscriptionQuotaListResult, or the result of cls(response) + :return: UserSubscriptionQuotaListResult or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_02.models.UserSubscriptionQuotaListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSubscriptionQuotaListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] - request = build_get_subscription_quota_request( subscription_id=self._config.subscription_id, - template_url=self.get_subscription_quota.metadata['url'], + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,12 +117,11 @@ def get_subscription_quota( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore - + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/__init__.py new file mode 100644 index 000000000000..6b2a2a8b0d68 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/__init__.py @@ -0,0 +1,24 @@ +# 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 ._iot_hub_client import IotHubClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_configuration.py new file mode 100644 index 000000000000..e1805d0f2a82 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_configuration.py @@ -0,0 +1,69 @@ +# 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 azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for IotHubClient. + + 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. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-04-30-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-04-30-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_iot_hub_client.py new file mode 100644 index 000000000000..e0472c913c1d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_iot_hub_client.py @@ -0,0 +1,128 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import IotHubClientConfiguration +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Use this API to manage the IoT hubs in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothub.v2022_04_30_preview.operations.Operations + :ivar iot_hub_resource: IotHubResourceOperations operations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2022_04_30_preview.operations.IotHubResourceOperations + :ivar resource_provider_common: ResourceProviderCommonOperations operations + :vartype resource_provider_common: + azure.mgmt.iothub.v2022_04_30_preview.operations.ResourceProviderCommonOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: azure.mgmt.iothub.v2022_04_30_preview.operations.CertificatesOperations + :ivar iot_hub: IotHubOperations operations + :vartype iot_hub: azure.mgmt.iothub.v2022_04_30_preview.operations.IotHubOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.iothub.v2022_04_30_preview.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2022_04_30_preview.operations.PrivateEndpointConnectionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-30-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(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._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> IotHubClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_metadata.json new file mode 100644 index 000000000000..d33e1d2d37e4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_metadata.json @@ -0,0 +1,108 @@ +{ + "chosen_version": "2022-04-30-preview", + "total_api_version_list": ["2022-04-30-preview"], + "client": { + "name": "IotHubClient", + "filename": "_iot_hub_client", + "description": "Use this API to manage the IoT hubs in your Azure subscription.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "iot_hub_resource": "IotHubResourceOperations", + "resource_provider_common": "ResourceProviderCommonOperations", + "certificates": "CertificatesOperations", + "iot_hub": "IotHubOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations" + } +} \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_version.py @@ -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" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/__init__.py new file mode 100644 index 000000000000..5d9bb0b6c365 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/__init__.py @@ -0,0 +1,21 @@ +# 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 ._iot_hub_client import IotHubClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["IotHubClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_configuration.py new file mode 100644 index 000000000000..d3fcede05d64 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_configuration.py @@ -0,0 +1,66 @@ +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for IotHubClient. + + 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. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-04-30-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-04-30-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".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 ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_iot_hub_client.py new file mode 100644 index 000000000000..47d922cd7247 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_iot_hub_client.py @@ -0,0 +1,126 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import IotHubClientConfiguration +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Use this API to manage the IoT hubs in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothub.v2022_04_30_preview.aio.operations.Operations + :ivar iot_hub_resource: IotHubResourceOperations operations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2022_04_30_preview.aio.operations.IotHubResourceOperations + :ivar resource_provider_common: ResourceProviderCommonOperations operations + :vartype resource_provider_common: + azure.mgmt.iothub.v2022_04_30_preview.aio.operations.ResourceProviderCommonOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: + azure.mgmt.iothub.v2022_04_30_preview.aio.operations.CertificatesOperations + :ivar iot_hub: IotHubOperations operations + :vartype iot_hub: azure.mgmt.iothub.v2022_04_30_preview.aio.operations.IotHubOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.iothub.v2022_04_30_preview.aio.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2022_04_30_preview.aio.operations.PrivateEndpointConnectionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-30-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(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._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "IotHubClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..901e21834b4d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# 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 ._operations import Operations +from ._iot_hub_resource_operations import IotHubResourceOperations +from ._resource_provider_common_operations import ResourceProviderCommonOperations +from ._certificates_operations import CertificatesOperations +from ._iot_hub_operations import IotHubOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_certificates_operations.py new file mode 100644 index 000000000000..b3d0d6abc7f9 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_certificates_operations.py @@ -0,0 +1,631 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.aio.IotHubClient`'s + :attr:`certificates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_iot_hub( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: + """Get the certificate list. + + Returns the list of certificates. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateListDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateListDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] + + request = build_list_by_iot_hub_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateListDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: + """Get the certificate. + + Returns the certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: Union[_models.CertificateDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. + :type certificate_description: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription or IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> None: + """Delete an X509 certificate. + + Deletes an existing X509 certificate or does nothing if it does not exist. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace_async + async def generate_verification_code( + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: + """Generate verification code for proof of possession flow. + + Generates verification code for proof of possession flow. The verification code will be used to + generate a leaf certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateWithNonceDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateWithNonceDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] + + request = build_generate_verification_code_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") + + request = build_verify_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_operations.py new file mode 100644 index 000000000000..11342fd1c2fc --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_operations.py @@ -0,0 +1,269 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.aio.IotHubClient`'s + :attr:`iot_hub` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2022_04_30_preview.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2022_04_30_preview.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._manual_failover_initial( # type: ignore + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + failover_input=failover_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_resource_operations.py new file mode 100644 index 000000000000..6d7dd2f8d504 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_resource_operations.py @@ -0,0 +1,2523 @@ +# pylint: disable=too-many-lines +# 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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: + """Get the non-security related metadata of an IoT hub. + + Get the non-security related metadata of an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription or + IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + async def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2022_04_30_preview.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2022_04_30_preview.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_tags=iot_hub_tags, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("ErrorDetails", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[AsyncLROPoller[_models.IotHubDescription], AsyncLROPoller[_models.ErrorDetails]]: + """Delete an IoT hub. + + Delete an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a subscription. + + Get all the IoT hubs in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a resource group. + + Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore + + @distributed_trace_async + async def get_stats( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: + """Get the statistics from an IoT hub. + + Get the statistics from an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryStatistics or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.RegistryStatistics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] + + request = build_get_stats_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryStatistics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore + + @distributed_trace + def get_valid_skus( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: + """Get the list of valid SKUs for an IoT hub. + + Get the list of valid SKUs for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubSkuDescription or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_valid_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore + + @distributed_trace + def list_event_hub_consumer_groups( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: + """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. + :type event_hub_endpoint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_event_hub_consumer_groups_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore + + @distributed_trace_async + async def get_event_hub_consumer_group( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to retrieve. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] + + request = build_get_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @distributed_trace_async + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @distributed_trace + def list_jobs( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: + """Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_jobs_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("JobResponseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore + + @distributed_trace_async + async def get_job( + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: + """Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param job_id: The job identifier. Required. + :type job_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + request = build_get_job_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore + + @distributed_trace + def get_quota_metrics( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: + """Get the quota metrics for an IoT hub. + + Get the quota metrics for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_quota_metrics_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore + + @distributed_trace + def get_endpoint_health( + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: + """Get the health for routing endpoints. + + Get the health for routing endpoints. + + :param resource_group_name: Required. + :type resource_group_name: str + :param iot_hub_name: Required. + :type iot_hub_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_endpoint_health_request( + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore + + @overload + async def check_name_availability( + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2022_04_30_preview.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2022_04_30_preview.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") + + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestRouteInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") + + request = build_test_route_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestRouteResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore + + @distributed_trace + def list_keys( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: + """Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_keys_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore + + @distributed_trace_async + async def get_keys_for_key_name( + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: + """Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param key_name: The name of the shared access policy. Required. + :type key_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.SharedAccessSignatureAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] + + request = build_get_keys_for_key_name_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2022_04_30_preview.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2022_04_30_preview.models.ExportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") + + request = build_export_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2022_04_30_preview.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2022_04_30_preview.models.ImportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") + + request = build_import_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..ba68bacc048a --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_operations.py @@ -0,0 +1,120 @@ +# pylint: disable=too-many-lines +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.aio.IotHubClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Lists all of the available IoT Hub REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..1295d4c847cd --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,546 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.aio.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: + """List private endpoint connections. + + List private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of PrivateEndpointConnection or the result of cls(response) + :rtype: list[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get private endpoint connection. + + Get private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Delete private endpoint connection. + + Delete private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..a3d7fd1016f3 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,167 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.aio.IotHubClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: + """List private link resources. + + List private link resources for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResources or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateLinkResources + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: + """Get the specified private link resource. + + Get the specified private link resource for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param group_id: The name of the private link resource. Required. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupIdInformation or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.GroupIdInformation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GroupIdInformation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_resource_provider_common_operations.py new file mode 100644 index 000000000000..8aebcdc7bc91 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_resource_provider_common_operations.py @@ -0,0 +1,100 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: + """Get the number of iot hubs in the subscription. + + Get the number of free and paid iot hubs in the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserSubscriptionQuotaListResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.UserSubscriptionQuotaListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/__init__.py new file mode 100644 index 000000000000..669dd46bf547 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/__init__.py @@ -0,0 +1,235 @@ +# 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 ._models_py3 import ArmIdentity +from ._models_py3 import ArmUserIdentity +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EncryptionPropertiesDescription +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupBodyDescription +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupName +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import GroupIdInformation +from ._models_py3 import GroupIdInformationProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubPropertiesDeviceStreams +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import KeyVaultKeyProperties +from ._models_py3 import ManagedIdentity +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import NetworkRuleSetIpRule +from ._models_py3 import NetworkRuleSetProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateLinkResources +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RootCertificateProperties +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingCosmosDBSqlApiProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import SystemData +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import AuthenticationType +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import CreatedByType +from ._iot_hub_client_enums import DefaultAction +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import NetworkRuleIPAction +from ._iot_hub_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_hub_client_enums import PublicNetworkAccess +from ._iot_hub_client_enums import ResourceIdentityType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ArmIdentity", + "ArmUserIdentity", + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EncryptionPropertiesDescription", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupBodyDescription", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupName", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "GroupIdInformation", + "GroupIdInformationProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubPropertiesDeviceStreams", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "KeyVaultKeyProperties", + "ManagedIdentity", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "NetworkRuleSetIpRule", + "NetworkRuleSetProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "RegistryStatistics", + "Resource", + "RootCertificateProperties", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingCosmosDBSqlApiProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "SystemData", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "AuthenticationType", + "Capabilities", + "CreatedByType", + "DefaultAction", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "NetworkRuleIPAction", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "ResourceIdentityType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_iot_hub_client_enums.py new file mode 100644 index 000000000000..2562e239f8a9 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_iot_hub_client_enums.py @@ -0,0 +1,231 @@ +# 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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" + + REGISTRY_READ = "RegistryRead" + REGISTRY_WRITE = "RegistryWrite" + SERVICE_CONNECT = "ServiceConnect" + DEVICE_CONNECT = "DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE = "RegistryRead, RegistryWrite" + REGISTRY_READ_SERVICE_CONNECT = "RegistryRead, ServiceConnect" + REGISTRY_READ_DEVICE_CONNECT = "RegistryRead, DeviceConnect" + REGISTRY_WRITE_SERVICE_CONNECT = "RegistryWrite, ServiceConnect" + REGISTRY_WRITE_DEVICE_CONNECT = "RegistryWrite, DeviceConnect" + SERVICE_CONNECT_DEVICE_CONNECT = "ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect" + REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" + REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" + REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) + + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies authentication type being used for connecting to the storage account.""" + + KEY_BASED = "keyBased" + IDENTITY_BASED = "identityBased" + + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" + + NONE = "None" + DEVICE_MANAGEMENT = "DeviceManagement" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default Action for Network Rule Set.""" + + DENY = "Deny" + ALLOW = "Allow" + + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Health statuses have following meanings. The 'healthy' status shows that the endpoint is + accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting + messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an + unhealthy endpoint will be updated to healthy when IoT Hub has established an eventually + consistent state of health. The 'dead' status shows that the endpoint is not accepting + messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to + identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub + has not established a connection with the endpoint. No messages have been delivered to or + rejected from this endpoint. + """ + + UNKNOWN = "unknown" + HEALTHY = "healthy" + DEGRADED = "degraded" + UNHEALTHY = "unhealthy" + DEAD = "dead" + + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" + + INVALID = "Invalid" + ALREADY_EXISTS = "AlreadyExists" + + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The role of the region, can be either primary or secondary. The primary region is where the IoT + hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired + region and also the region where the IoT hub can failover to. + """ + + PRIMARY = "primary" + SECONDARY = "secondary" + + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" + + AUTOMATIC = "Automatic" + MANUAL = "Manual" + NONE = "None" + + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" + + F1 = "F1" + S1 = "S1" + S2 = "S2" + S3 = "S3" + B1 = "B1" + B2 = "B2" + B3 = "B3" + + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" + + FREE = "Free" + STANDARD = "Standard" + BASIC = "Basic" + + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" + + ACCEPT = "Accept" + REJECT = "Reject" + + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" + + UNKNOWN = "unknown" + ENQUEUED = "enqueued" + RUNNING = "running" + COMPLETED = "completed" + FAILED = "failed" + CANCELLED = "cancelled" + + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" + + UNKNOWN = "unknown" + EXPORT = "export" + IMPORT = "import" + BACKUP = "backup" + READ_DEVICE_PROPERTIES = "readDeviceProperties" + WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" + UPDATE_DEVICE_CONFIGURATION = "updateDeviceConfiguration" + REBOOT_DEVICE = "rebootDevice" + FACTORY_RESET_DEVICE = "factoryResetDevice" + FIRMWARE_UPDATE = "firmwareUpdate" + + +class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP Filter Action.""" + + ALLOW = "Allow" + + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes + both an implicitly created identity and a set of user assigned identities. The type 'None' will + remove any identities from the service. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" + + ERROR = "error" + WARNING = "warning" + + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" + + INVALID = "Invalid" + DEVICE_MESSAGES = "DeviceMessages" + TWIN_CHANGE_EVENTS = "TwinChangeEvents" + DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" + DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" + DIGITAL_TWIN_CHANGE_EVENTS = "DigitalTwinChangeEvents" + DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" + MQTT_BROKER_MESSAGES = "MqttBrokerMessages" + + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Encoding that is used to serialize messages to blobs. Supported values are 'avro', + 'avrodeflate', and 'JSON'. Default value is 'avro'. + """ + + AVRO = "Avro" + AVRO_DEFLATE = "AvroDeflate" + JSON = "JSON" + + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" + + UNDEFINED = "undefined" + FALSE = "false" + TRUE = "true" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_models_py3.py new file mode 100644 index 000000000000..a57fdd80d183 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_models_py3.py @@ -0,0 +1,4236 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +import datetime +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class ArmIdentity(_serialization.Model): + """ArmIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: Principal Id. + :vartype principal_id: str + :ivar tenant_id: Tenant Id. + :vartype tenant_id: str + :ivar type: The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' + includes both an implicitly created identity and a set of user assigned identities. The type + 'None' will remove any identities from the service. Known values are: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :vartype type: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.ResourceIdentityType + :ivar user_assigned_identities: Dictionary of :code:``. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2022_04_30_preview.models.ArmUserIdentity] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{ArmUserIdentity}"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ArmUserIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The type of identity used for the resource. The type + 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user + assigned identities. The type 'None' will remove any identities from the service. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :paramtype type: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.ResourceIdentityType + :keyword user_assigned_identities: Dictionary of :code:``. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2022_04_30_preview.models.ArmUserIdentity] + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ArmUserIdentity(_serialization.Model): + """ArmUserIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: + :vartype principal_id: str + :ivar client_id: + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class CertificateBodyDescription(_serialization.Model): + """The JSON-serialized X509 Certificate. + + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + file content. + :vartype certificate: str + :ivar is_verified: True indicates that the certificate will be created in verified state and + proof of possession will not be required. + :vartype is_verified: bool + """ + + _attribute_map = { + "certificate": {"key": "certificate", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + } + + def __init__(self, *, certificate: Optional[str] = None, is_verified: Optional[bool] = None, **kwargs): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + :keyword is_verified: True indicates that the certificate will be created in verified state and + proof of possession will not be required. + :paramtype is_verified: bool + """ + super().__init__(**kwargs) + self.certificate = certificate + self.is_verified = is_verified + + +class CertificateDescription(_serialization.Model): + """The X509 Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateProperties + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The name of the certificate. + :vartype name: str + :ivar etag: The entity tag. + :vartype etag: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateProperties + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.etag = None + self.type = None + + +class CertificateListDescription(_serialization.Model): + """The JSON-serialized array of Certificate objects. + + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CertificateDescription]"}, + } + + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription] + """ + super().__init__(**kwargs) + self.value = value + + +class CertificateProperties(_serialization.Model): + """The description of an X509 CA Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subject: The certificate's subject name. + :vartype subject: str + :ivar expiry: The certificate's expiration date and time. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: The certificate's thumbprint. + :vartype thumbprint: str + :ivar is_verified: Determines whether certificate has been verified. + :vartype is_verified: bool + :ivar created: The certificate's create date and time. + :vartype created: ~datetime.datetime + :ivar updated: The certificate's last update date and time. + :vartype updated: ~datetime.datetime + :ivar certificate: The certificate content. + :vartype certificate: str + """ + + _validation = { + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, *, is_verified: Optional[bool] = None, certificate: Optional[str] = None, **kwargs): + """ + :keyword is_verified: Determines whether certificate has been verified. + :paramtype is_verified: bool + :keyword certificate: The certificate content. + :paramtype certificate: str + """ + super().__init__(**kwargs) + self.subject = None + self.expiry = None + self.thumbprint = None + self.is_verified = is_verified + self.created = None + self.updated = None + self.certificate = certificate + + +class CertificatePropertiesWithNonce(_serialization.Model): + """The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subject: The certificate's subject name. + :vartype subject: str + :ivar expiry: The certificate's expiration date and time. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: The certificate's thumbprint. + :vartype thumbprint: str + :ivar is_verified: Determines whether certificate has been verified. + :vartype is_verified: bool + :ivar created: The certificate's create date and time. + :vartype created: ~datetime.datetime + :ivar updated: The certificate's last update date and time. + :vartype updated: ~datetime.datetime + :ivar verification_code: The certificate's verification code that will be used for proof of + possession. + :vartype verification_code: str + :ivar certificate: The certificate content. + :vartype certificate: str + """ + + _validation = { + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.subject = None + self.expiry = None + self.thumbprint = None + self.is_verified = None + self.created = None + self.updated = None + self.verification_code = None + self.certificate = None + + +class CertificateVerificationDescription(_serialization.Model): + """The JSON-serialized leaf certificate. + + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :vartype certificate: str + """ + + _attribute_map = { + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, *, certificate: Optional[str] = None, **kwargs): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ + super().__init__(**kwargs) + self.certificate = certificate + + +class CertificateWithNonceDescription(_serialization.Model): + """The X509 Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The description of an X509 CA Certificate including the challenge nonce + issued for the Proof-Of-Possession flow. + :vartype properties: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificatePropertiesWithNonce + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The name of the certificate. + :vartype name: str + :ivar etag: The entity tag. + :vartype etag: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs): + """ + :keyword properties: The description of an X509 CA Certificate including the challenge nonce + issued for the Proof-Of-Possession flow. + :paramtype properties: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificatePropertiesWithNonce + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.etag = None + self.type = None + + +class CloudToDeviceProperties(_serialization.Model): + """The IoT hub cloud-to-device messaging properties. + + :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device + queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype max_delivery_count: int + :ivar default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + device queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype default_ttl_as_iso8601: ~datetime.timedelta + :ivar feedback: The properties of the feedback queue for cloud-to-device messages. + :vartype feedback: ~azure.mgmt.iothub.v2022_04_30_preview.models.FeedbackProperties + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, + } + + def __init__( + self, + *, + max_delivery_count: Optional[int] = None, + default_ttl_as_iso8601: Optional[datetime.timedelta] = None, + feedback: Optional["_models.FeedbackProperties"] = None, + **kwargs + ): + """ + :keyword max_delivery_count: The max delivery count for cloud-to-device messages in the device + queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype max_delivery_count: int + :keyword default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + device queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype default_ttl_as_iso8601: ~datetime.timedelta + :keyword feedback: The properties of the feedback queue for cloud-to-device messages. + :paramtype feedback: ~azure.mgmt.iothub.v2022_04_30_preview.models.FeedbackProperties + """ + super().__init__(**kwargs) + self.max_delivery_count = max_delivery_count + self.default_ttl_as_iso8601 = default_ttl_as_iso8601 + self.feedback = feedback + + +class EncryptionPropertiesDescription(_serialization.Model): + """The encryption properties for the IoT hub. + + :ivar key_source: The source of the key. + :vartype key_source: str + :ivar key_vault_properties: The properties of the KeyVault key. + :vartype key_vault_properties: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.KeyVaultKeyProperties] + """ + + _attribute_map = { + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultKeyProperties]"}, + } + + def __init__( + self, + *, + key_source: Optional[str] = None, + key_vault_properties: Optional[List["_models.KeyVaultKeyProperties"]] = None, + **kwargs + ): + """ + :keyword key_source: The source of the key. + :paramtype key_source: str + :keyword key_vault_properties: The properties of the KeyVault key. + :paramtype key_vault_properties: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.KeyVaultKeyProperties] + """ + super().__init__(**kwargs) + self.key_source = key_source + self.key_vault_properties = key_vault_properties + + +class EndpointHealthData(_serialization.Model): + """The health data for an endpoint. + + :ivar endpoint_id: Id of the endpoint. + :vartype endpoint_id: str + :ivar health_status: Health statuses have following meanings. The 'healthy' status shows that + the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint + is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. + The status of an unhealthy endpoint will be updated to healthy when IoT Hub has established an + eventually consistent state of health. The 'dead' status shows that the endpoint is not + accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub + metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that + the IoT Hub has not established a connection with the endpoint. No messages have been delivered + to or rejected from this endpoint. Known values are: "unknown", "healthy", "degraded", + "unhealthy", and "dead". + :vartype health_status: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.EndpointHealthStatus + :ivar last_known_error: Last error obtained when a message failed to be delivered to iot hub. + :vartype last_known_error: str + :ivar last_known_error_time: Time at which the last known error occurred. + :vartype last_known_error_time: ~datetime.datetime + :ivar last_successful_send_attempt_time: Last time iot hub successfully sent a message to the + endpoint. + :vartype last_successful_send_attempt_time: ~datetime.datetime + :ivar last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. + :vartype last_send_attempt_time: ~datetime.datetime + """ + + _attribute_map = { + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, + "last_known_error": {"key": "lastKnownError", "type": "str"}, + "last_known_error_time": {"key": "lastKnownErrorTime", "type": "rfc-1123"}, + "last_successful_send_attempt_time": {"key": "lastSuccessfulSendAttemptTime", "type": "rfc-1123"}, + "last_send_attempt_time": {"key": "lastSendAttemptTime", "type": "rfc-1123"}, + } + + def __init__( + self, + *, + endpoint_id: Optional[str] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, + last_known_error: Optional[str] = None, + last_known_error_time: Optional[datetime.datetime] = None, + last_successful_send_attempt_time: Optional[datetime.datetime] = None, + last_send_attempt_time: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword endpoint_id: Id of the endpoint. + :paramtype endpoint_id: str + :keyword health_status: Health statuses have following meanings. The 'healthy' status shows + that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the + endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this + endpoint. The status of an unhealthy endpoint will be updated to healthy when IoT Hub has + established an eventually consistent state of health. The 'dead' status shows that the endpoint + is not accepting messages, after IoT Hub retried sending messages for the retrial period. See + IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status + shows that the IoT Hub has not established a connection with the endpoint. No messages have + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "degraded", "unhealthy", and "dead". + :paramtype health_status: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.EndpointHealthStatus + :keyword last_known_error: Last error obtained when a message failed to be delivered to iot + hub. + :paramtype last_known_error: str + :keyword last_known_error_time: Time at which the last known error occurred. + :paramtype last_known_error_time: ~datetime.datetime + :keyword last_successful_send_attempt_time: Last time iot hub successfully sent a message to + the endpoint. + :paramtype last_successful_send_attempt_time: ~datetime.datetime + :keyword last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. + :paramtype last_send_attempt_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.endpoint_id = endpoint_id + self.health_status = health_status + self.last_known_error = last_known_error + self.last_known_error_time = last_known_error_time + self.last_successful_send_attempt_time = last_successful_send_attempt_time + self.last_send_attempt_time = last_send_attempt_time + + +class EndpointHealthDataListResult(_serialization.Model): + """The JSON-serialized array of EndpointHealthData objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.EndpointHealthData] + :ivar next_link: Link to more results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.EndpointHealthData] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class EnrichmentProperties(_serialization.Model): + """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. + + All required parameters must be populated in order to send to Azure. + + :ivar key: The key or name for the enrichment property. Required. + :vartype key: str + :ivar value: The value for the enrichment property. Required. + :vartype value: str + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. + :vartype endpoint_names: list[str] + """ + + _validation = { + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, + } + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + } + + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs): + """ + :keyword key: The key or name for the enrichment property. Required. + :paramtype key: str + :keyword value: The value for the enrichment property. Required. + :paramtype value: str + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. + :paramtype endpoint_names: list[str] + """ + super().__init__(**kwargs) + self.key = key + self.value = value + self.endpoint_names = endpoint_names + + +class ErrorDetails(_serialization.Model): + """Error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar http_status_code: The HTTP status code. + :vartype http_status_code: str + :ivar message: The error message. + :vartype message: str + :ivar details: The error details. + :vartype details: str + """ + + _validation = { + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.code = None + self.http_status_code = None + self.message = None + self.details = None + + +class EventHubConsumerGroupBodyDescription(_serialization.Model): + """The EventHub consumer group. + + All required parameters must be populated in order to send to Azure. + + :ivar properties: The EventHub consumer group name. Required. + :vartype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupName + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "EventHubConsumerGroupName"}, + } + + def __init__(self, *, properties: "_models.EventHubConsumerGroupName", **kwargs): + """ + :keyword properties: The EventHub consumer group name. Required. + :paramtype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupName + """ + super().__init__(**kwargs) + self.properties = properties + + +class EventHubConsumerGroupInfo(_serialization.Model): + """The properties of the EventHubConsumerGroupInfo object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The tags. + :vartype properties: dict[str, any] + :ivar id: The Event Hub-compatible consumer group identifier. + :vartype id: str + :ivar name: The Event Hub-compatible consumer group name. + :vartype name: str + :ivar type: the resource type. + :vartype type: str + :ivar etag: The etag. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "{object}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, any] + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.type = None + self.etag = None + + +class EventHubConsumerGroupName(_serialization.Model): + """The EventHub consumer group name. + + All required parameters must be populated in order to send to Azure. + + :ivar name: EventHub consumer group name. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: EventHub consumer group name. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class EventHubConsumerGroupsListResult(_serialization.Model): + """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class EventHubProperties(_serialization.Model): + """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :vartype retention_time_in_days: int + :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the + Event Hub-compatible endpoint. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :vartype partition_count: int + :ivar partition_ids: The partition ids in the Event Hub-compatible endpoint. + :vartype partition_ids: list[str] + :ivar path: The Event Hub-compatible name. + :vartype path: str + :ivar endpoint: The Event Hub-compatible endpoint. + :vartype endpoint: str + """ + + _validation = { + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, + } + + _attribute_map = { + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, + } + + def __init__( + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs + ): + """ + :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :paramtype retention_time_in_days: int + :keyword partition_count: The number of partitions for receiving device-to-cloud messages in + the Event Hub-compatible endpoint. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :paramtype partition_count: int + """ + super().__init__(**kwargs) + self.retention_time_in_days = retention_time_in_days + self.partition_count = partition_count + self.partition_ids = None + self.path = None + self.endpoint = None + + +class ExportDevicesRequest(_serialization.Model): + """Use to provide parameters when requesting an export of all devices in the IoT hub. + + All required parameters must be populated in order to send to Azure. + + :ivar export_blob_container_uri: The export blob container URI. Required. + :vartype export_blob_container_uri: str + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. + :vartype exclude_keys: bool + :ivar export_blob_name: The name of the blob that will be created in the provided output blob + container. This blob will contain the exported device registry information for the IoT Hub. + :vartype export_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for export devices. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :ivar include_configurations: The value indicating whether configurations should be exported. + :vartype include_configurations: bool + :ivar configurations_blob_name: The name of the blob that will be created in the provided + output blob container. This blob will contain the exported configurations for the Iot Hub. + :vartype configurations_blob_name: str + """ + + _validation = { + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, + } + + _attribute_map = { + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, + "export_blob_name": {"key": "exportBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, + } + + def __init__( + self, + *, + export_blob_container_uri: str, + exclude_keys: bool, + export_blob_name: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + include_configurations: Optional[bool] = None, + configurations_blob_name: Optional[str] = None, + **kwargs + ): + """ + :keyword export_blob_container_uri: The export blob container URI. Required. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. + :paramtype exclude_keys: bool + :keyword export_blob_name: The name of the blob that will be created in the provided output + blob container. This blob will contain the exported device registry information for the IoT + Hub. + :paramtype export_blob_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for export devices. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :keyword include_configurations: The value indicating whether configurations should be + exported. + :paramtype include_configurations: bool + :keyword configurations_blob_name: The name of the blob that will be created in the provided + output blob container. This blob will contain the exported configurations for the Iot Hub. + :paramtype configurations_blob_name: str + """ + super().__init__(**kwargs) + self.export_blob_container_uri = export_blob_container_uri + self.exclude_keys = exclude_keys + self.export_blob_name = export_blob_name + self.authentication_type = authentication_type + self.identity = identity + self.include_configurations = include_configurations + self.configurations_blob_name = configurations_blob_name + + +class FailoverInput(_serialization.Model): + """Use to provide failover region when requesting manual Failover for a hub. + + All required parameters must be populated in order to send to Azure. + + :ivar failover_region: Region the hub will be failed over to. Required. + :vartype failover_region: str + """ + + _validation = { + "failover_region": {"required": True}, + } + + _attribute_map = { + "failover_region": {"key": "failoverRegion", "type": "str"}, + } + + def __init__(self, *, failover_region: str, **kwargs): + """ + :keyword failover_region: Region the hub will be failed over to. Required. + :paramtype failover_region: str + """ + super().__init__(**kwargs) + self.failover_region = failover_region + + +class FallbackRouteProperties(_serialization.Model): + """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :vartype name: str + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :vartype source: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingSource + :ivar condition: The condition which is evaluated in order to apply the fallback route. If the + condition is not provided it will evaluate to true by default. For grammar, See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :vartype condition: str + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. + :vartype endpoint_names: list[str] + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. + :vartype is_enabled: bool + """ + + _validation = { + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + source: Union[str, "_models.RoutingSource"], + endpoint_names: List[str], + is_enabled: bool, + name: Optional[str] = None, + condition: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :paramtype name: str + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :paramtype source: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingSource + :keyword condition: The condition which is evaluated in order to apply the fallback route. If + the condition is not provided it will evaluate to true by default. For grammar, See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :paramtype condition: str + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.name = name + self.source = source + self.condition = condition + self.endpoint_names = endpoint_names + self.is_enabled = is_enabled + + +class FeedbackProperties(_serialization.Model): + """The properties of the feedback queue for cloud-to-device messages. + + :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype lock_duration_as_iso8601: ~datetime.timedelta + :ivar ttl_as_iso8601: The period of time for which a message is available to consume before it + is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype ttl_as_iso8601: ~datetime.timedelta + :ivar max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype max_delivery_count: int + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + } + + def __init__( + self, + *, + lock_duration_as_iso8601: Optional[datetime.timedelta] = None, + ttl_as_iso8601: Optional[datetime.timedelta] = None, + max_delivery_count: Optional[int] = None, + **kwargs + ): + """ + :keyword lock_duration_as_iso8601: The lock duration for the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype lock_duration_as_iso8601: ~datetime.timedelta + :keyword ttl_as_iso8601: The period of time for which a message is available to consume before + it is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype ttl_as_iso8601: ~datetime.timedelta + :keyword max_delivery_count: The number of times the IoT hub attempts to deliver a message on + the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype max_delivery_count: int + """ + super().__init__(**kwargs) + self.lock_duration_as_iso8601 = lock_duration_as_iso8601 + self.ttl_as_iso8601 = ttl_as_iso8601 + self.max_delivery_count = max_delivery_count + + +class GroupIdInformation(_serialization.Model): + """The group information for creating a private endpoint on an IotHub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar properties: The properties for a group information object. Required. + :vartype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.GroupIdInformationProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, + } + + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs): + """ + :keyword properties: The properties for a group information object. Required. + :paramtype properties: + ~azure.mgmt.iothub.v2022_04_30_preview.models.GroupIdInformationProperties + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class GroupIdInformationProperties(_serialization.Model): + """The properties for a group information object. + + :ivar group_id: The group id. + :vartype group_id: str + :ivar required_members: The required members for a specific group id. + :vartype required_members: list[str] + :ivar required_zone_names: The required DNS zones for a specific group id. + :vartype required_zone_names: list[str] + """ + + _attribute_map = { + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, + } + + def __init__( + self, + *, + group_id: Optional[str] = None, + required_members: Optional[List[str]] = None, + required_zone_names: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword group_id: The group id. + :paramtype group_id: str + :keyword required_members: The required members for a specific group id. + :paramtype required_members: list[str] + :keyword required_zone_names: The required DNS zones for a specific group id. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.group_id = group_id + self.required_members = required_members + self.required_zone_names = required_zone_names + + +class ImportDevicesRequest(_serialization.Model): + """Use to provide parameters when requesting an import of all devices in the hub. + + All required parameters must be populated in order to send to Azure. + + :ivar input_blob_container_uri: The input blob container URI. Required. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: The output blob container URI. Required. + :vartype output_blob_container_uri: str + :ivar input_blob_name: The blob name to be used when importing from the provided input blob + container. + :vartype input_blob_name: str + :ivar output_blob_name: The blob name to use for storing the status of the import job. + :vartype output_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for import devices. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :ivar include_configurations: The value indicating whether configurations should be imported. + :vartype include_configurations: bool + :ivar configurations_blob_name: The blob name to be used when importing configurations from the + provided input blob container. + :vartype configurations_blob_name: str + """ + + _validation = { + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, + } + + _attribute_map = { + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, + "input_blob_name": {"key": "inputBlobName", "type": "str"}, + "output_blob_name": {"key": "outputBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, + } + + def __init__( + self, + *, + input_blob_container_uri: str, + output_blob_container_uri: str, + input_blob_name: Optional[str] = None, + output_blob_name: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + include_configurations: Optional[bool] = None, + configurations_blob_name: Optional[str] = None, + **kwargs + ): + """ + :keyword input_blob_container_uri: The input blob container URI. Required. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: The output blob container URI. Required. + :paramtype output_blob_container_uri: str + :keyword input_blob_name: The blob name to be used when importing from the provided input blob + container. + :paramtype input_blob_name: str + :keyword output_blob_name: The blob name to use for storing the status of the import job. + :paramtype output_blob_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for import devices. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :keyword include_configurations: The value indicating whether configurations should be + imported. + :paramtype include_configurations: bool + :keyword configurations_blob_name: The blob name to be used when importing configurations from + the provided input blob container. + :paramtype configurations_blob_name: str + """ + super().__init__(**kwargs) + self.input_blob_container_uri = input_blob_container_uri + self.output_blob_container_uri = output_blob_container_uri + self.input_blob_name = input_blob_name + self.output_blob_name = output_blob_name + self.authentication_type = authentication_type + self.identity = identity + self.include_configurations = include_configurations + self.configurations_blob_name = configurations_blob_name + + +class IotHubCapacity(_serialization.Model): + """IoT Hub capacity information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar minimum: The minimum number of units. + :vartype minimum: int + :ivar maximum: The maximum number of units. + :vartype maximum: int + :ivar default: The default number of units. + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". + :vartype scale_type: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubScaleType + """ + + _validation = { + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, + } + + _attribute_map = { + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.minimum = None + self.maximum = None + self.default = None + self.scale_type = None + + +class Resource(_serialization.Model): + """The common properties of an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar location: The resource location. Required. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword location: The resource location. Required. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class IotHubDescription(Resource): + """The description of the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar location: The resource location. Required. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal ETag convention. + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubProperties + :ivar sku: IotHub SKU info. Required. + :vartype sku: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuInfo + :ivar identity: The managed identities for the IotHub. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ArmIdentity + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.iothub.v2022_04_30_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "identity": {"key": "identity", "type": "ArmIdentity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__( + self, + *, + location: str, + sku: "_models.IotHubSkuInfo", + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + properties: Optional["_models.IotHubProperties"] = None, + identity: Optional["_models.ArmIdentity"] = None, + **kwargs + ): + """ + :keyword location: The resource location. Required. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + :keyword etag: The Etag field is *not* required. If it is provided in the response body, it + must also be provided as a header per the normal ETag convention. + :paramtype etag: str + :keyword properties: IotHub properties. + :paramtype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubProperties + :keyword sku: IotHub SKU info. Required. + :paramtype sku: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuInfo + :keyword identity: The managed identities for the IotHub. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ArmIdentity + """ + super().__init__(location=location, tags=tags, **kwargs) + self.etag = etag + self.properties = properties + self.sku = sku + self.identity = identity + self.system_data = None + + +class IotHubDescriptionListResult(_serialization.Model): + """The JSON-serialized array of IotHubDescription objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubLocationDescription(_serialization.Model): + """Public representation of one of the locations where a resource is provisioned. + + :ivar location: The name of the Azure region. + :vartype location: str + :ivar role: The role of the region, can be either primary or secondary. The primary region is + where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". + :vartype role: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubReplicaRoleType + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, + **kwargs + ): + """ + :keyword location: The name of the Azure region. + :paramtype location: str + :keyword role: The role of the region, can be either primary or secondary. The primary region + is where the IoT hub is currently provisioned. The secondary region is the Azure disaster + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubReplicaRoleType + """ + super().__init__(**kwargs) + self.location = location + self.role = role + + +class IotHubNameAvailabilityInfo(_serialization.Model): + """The properties indicating whether a given IoT hub name is available. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: The value which indicates whether the provided name is available. + :vartype name_available: bool + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". + :vartype reason: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubNameUnavailabilityReason + :ivar message: The detailed reason message. + :vartype message: str + """ + + _validation = { + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + } + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, message: Optional[str] = None, **kwargs): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ + super().__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = message + + +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties of an IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar authorization_policies: The shared access policies you can use to secure a connection to + the IoT hub. + :vartype authorization_policies: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.SharedAccessSignatureAuthorizationRule] + :ivar disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used for + authentication. + :vartype disable_local_auth: bool + :ivar disable_device_sas: If true, all device(including Edge devices but excluding modules) + scoped SAS keys cannot be used for authentication. + :vartype disable_device_sas: bool + :ivar disable_module_sas: If true, all module scoped SAS keys cannot be used for + authentication. + :vartype disable_module_sas: bool + :ivar restrict_outbound_network_access: If true, egress from IotHub will be restricted to only + the allowed FQDNs that are configured via allowedFqdnList. + :vartype restrict_outbound_network_access: bool + :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot + Hub. + :vartype allowed_fqdn_list: list[str] + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.PublicNetworkAccess + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2022_04_30_preview.models.IpFilterRule] + :ivar network_rule_sets: Network Rule Set Properties of IotHub. + :vartype network_rule_sets: + ~azure.mgmt.iothub.v2022_04_30_preview.models.NetworkRuleSetProperties + :ivar min_tls_version: Specifies the minimum TLS version to support for this hub. Can be set to + "1.2" to have clients that use a TLS version below 1.2 to be rejected. + :vartype min_tls_version: str + :ivar private_endpoint_connections: Private endpoint connections created on this IotHub. + :vartype private_endpoint_connections: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + :ivar state: The hub state. + :vartype state: str + :ivar host_name: The name of the host. + :vartype host_name: str + :ivar event_hub_endpoints: The Event Hub-compatible endpoint properties. The only possible keys + to this dictionary is events. This key has to be present in the dictionary while making create + or update calls for the IoT hub. + :vartype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + :vartype routing: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingProperties + :ivar storage_endpoints: The list of Azure Storage endpoints where you can upload files. + Currently you can configure only one Azure Storage account and that MUST have its key as + $default. Specifying more than one storage account causes an error to be thrown. Not specifying + a value for this property when the enableFileUploadNotifications property is set to True, + causes an error to be thrown. + :vartype storage_endpoints: dict[str, + ~azure.mgmt.iothub.v2022_04_30_preview.models.StorageEndpointProperties] + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification + queue. + :vartype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2022_04_30_preview.models.MessagingEndpointProperties] + :ivar enable_file_upload_notifications: If True, file upload notifications are enabled. + :vartype enable_file_upload_notifications: bool + :ivar cloud_to_device: The IoT hub cloud-to-device messaging properties. + :vartype cloud_to_device: ~azure.mgmt.iothub.v2022_04_30_preview.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar device_streams: The device streams properties of iothub. + :vartype device_streams: + ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubPropertiesDeviceStreams + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.Capabilities + :ivar encryption: The encryption properties for the IoT hub. + :vartype encryption: + ~azure.mgmt.iothub.v2022_04_30_preview.models.EncryptionPropertiesDescription + :ivar locations: Primary and secondary location for iot hub. + :vartype locations: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubLocationDescription] + :ivar enable_data_residency: This property when set to true, will enable data residency, thus, + disabling disaster recovery. + :vartype enable_data_residency: bool + :ivar root_certificate: This property store root certificate related information. + :vartype root_certificate: + ~azure.mgmt.iothub.v2022_04_30_preview.models.RootCertificateProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "disable_local_auth": {"key": "disableLocalAuth", "type": "bool"}, + "disable_device_sas": {"key": "disableDeviceSAS", "type": "bool"}, + "disable_module_sas": {"key": "disableModuleSAS", "type": "bool"}, + "restrict_outbound_network_access": {"key": "restrictOutboundNetworkAccess", "type": "bool"}, + "allowed_fqdn_list": {"key": "allowedFqdnList", "type": "[str]"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "network_rule_sets": {"key": "networkRuleSets", "type": "NetworkRuleSetProperties"}, + "min_tls_version": {"key": "minTlsVersion", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "device_streams": {"key": "deviceStreams", "type": "IotHubPropertiesDeviceStreams"}, + "features": {"key": "features", "type": "str"}, + "encryption": {"key": "encryption", "type": "EncryptionPropertiesDescription"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, + "enable_data_residency": {"key": "enableDataResidency", "type": "bool"}, + "root_certificate": {"key": "rootCertificate", "type": "RootCertificateProperties"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + disable_local_auth: Optional[bool] = None, + disable_device_sas: Optional[bool] = None, + disable_module_sas: Optional[bool] = None, + restrict_outbound_network_access: Optional[bool] = None, + allowed_fqdn_list: Optional[List[str]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + network_rule_sets: Optional["_models.NetworkRuleSetProperties"] = None, + min_tls_version: Optional[str] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, + enable_file_upload_notifications: Optional[bool] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, + comments: Optional[str] = None, + device_streams: Optional["_models.IotHubPropertiesDeviceStreams"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, + encryption: Optional["_models.EncryptionPropertiesDescription"] = None, + enable_data_residency: Optional[bool] = None, + root_certificate: Optional["_models.RootCertificateProperties"] = None, + **kwargs + ): + """ + :keyword authorization_policies: The shared access policies you can use to secure a connection + to the IoT hub. + :paramtype authorization_policies: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.SharedAccessSignatureAuthorizationRule] + :keyword disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used + for authentication. + :paramtype disable_local_auth: bool + :keyword disable_device_sas: If true, all device(including Edge devices but excluding modules) + scoped SAS keys cannot be used for authentication. + :paramtype disable_device_sas: bool + :keyword disable_module_sas: If true, all module scoped SAS keys cannot be used for + authentication. + :paramtype disable_module_sas: bool + :keyword restrict_outbound_network_access: If true, egress from IotHub will be restricted to + only the allowed FQDNs that are configured via allowedFqdnList. + :paramtype restrict_outbound_network_access: bool + :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from + Iot Hub. + :paramtype allowed_fqdn_list: list[str] + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.PublicNetworkAccess + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2022_04_30_preview.models.IpFilterRule] + :keyword network_rule_sets: Network Rule Set Properties of IotHub. + :paramtype network_rule_sets: + ~azure.mgmt.iothub.v2022_04_30_preview.models.NetworkRuleSetProperties + :keyword min_tls_version: Specifies the minimum TLS version to support for this hub. Can be set + to "1.2" to have clients that use a TLS version below 1.2 to be rejected. + :paramtype min_tls_version: str + :keyword private_endpoint_connections: Private endpoint connections created on this IotHub. + :paramtype private_endpoint_connections: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The only possible + keys to this dictionary is events. This key has to be present in the dictionary while making + create or update calls for the IoT hub. + :paramtype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubProperties] + :keyword routing: The routing related properties of the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + :paramtype routing: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingProperties + :keyword storage_endpoints: The list of Azure Storage endpoints where you can upload files. + Currently you can configure only one Azure Storage account and that MUST have its key as + $default. Specifying more than one storage account causes an error to be thrown. Not specifying + a value for this property when the enableFileUploadNotifications property is set to True, + causes an error to be thrown. + :paramtype storage_endpoints: dict[str, + ~azure.mgmt.iothub.v2022_04_30_preview.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2022_04_30_preview.models.MessagingEndpointProperties] + :keyword enable_file_upload_notifications: If True, file upload notifications are enabled. + :paramtype enable_file_upload_notifications: bool + :keyword cloud_to_device: The IoT hub cloud-to-device messaging properties. + :paramtype cloud_to_device: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword device_streams: The device streams properties of iothub. + :paramtype device_streams: + ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubPropertiesDeviceStreams + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.Capabilities + :keyword encryption: The encryption properties for the IoT hub. + :paramtype encryption: + ~azure.mgmt.iothub.v2022_04_30_preview.models.EncryptionPropertiesDescription + :keyword enable_data_residency: This property when set to true, will enable data residency, + thus, disabling disaster recovery. + :paramtype enable_data_residency: bool + :keyword root_certificate: This property store root certificate related information. + :paramtype root_certificate: + ~azure.mgmt.iothub.v2022_04_30_preview.models.RootCertificateProperties + """ + super().__init__(**kwargs) + self.authorization_policies = authorization_policies + self.disable_local_auth = disable_local_auth + self.disable_device_sas = disable_device_sas + self.disable_module_sas = disable_module_sas + self.restrict_outbound_network_access = restrict_outbound_network_access + self.allowed_fqdn_list = allowed_fqdn_list + self.public_network_access = public_network_access + self.ip_filter_rules = ip_filter_rules + self.network_rule_sets = network_rule_sets + self.min_tls_version = min_tls_version + self.private_endpoint_connections = private_endpoint_connections + self.provisioning_state = None + self.state = None + self.host_name = None + self.event_hub_endpoints = event_hub_endpoints + self.routing = routing + self.storage_endpoints = storage_endpoints + self.messaging_endpoints = messaging_endpoints + self.enable_file_upload_notifications = enable_file_upload_notifications + self.cloud_to_device = cloud_to_device + self.comments = comments + self.device_streams = device_streams + self.features = features + self.encryption = encryption + self.locations = None + self.enable_data_residency = enable_data_residency + self.root_certificate = root_certificate + + +class IotHubPropertiesDeviceStreams(_serialization.Model): + """The device streams properties of iothub. + + :ivar streaming_endpoints: List of Device Streams Endpoints. + :vartype streaming_endpoints: list[str] + """ + + _attribute_map = { + "streaming_endpoints": {"key": "streamingEndpoints", "type": "[str]"}, + } + + def __init__(self, *, streaming_endpoints: Optional[List[str]] = None, **kwargs): + """ + :keyword streaming_endpoints: List of Device Streams Endpoints. + :paramtype streaming_endpoints: list[str] + """ + super().__init__(**kwargs) + self.streaming_endpoints = streaming_endpoints + + +class IotHubQuotaMetricInfo(_serialization.Model): + """Quota metrics properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the quota metric. + :vartype name: str + :ivar current_value: The current value for the quota metric. + :vartype current_value: int + :ivar max_value: The maximum value of the quota metric. + :vartype max_value: int + """ + + _validation = { + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.current_value = None + self.max_value = None + + +class IotHubQuotaMetricInfoListResult(_serialization.Model): + """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubQuotaMetricInfo] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubQuotaMetricInfo] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubSkuDescription(_serialization.Model): + """SKU properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar resource_type: The type of the resource. + :vartype resource_type: str + :ivar sku: The type of the resource. Required. + :vartype sku: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuInfo + :ivar capacity: IotHub capacity. Required. + :vartype capacity: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubCapacity + """ + + _validation = { + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, + } + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, + } + + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs): + """ + :keyword sku: The type of the resource. Required. + :paramtype sku: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuInfo + :keyword capacity: IotHub capacity. Required. + :paramtype capacity: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubCapacity + """ + super().__init__(**kwargs) + self.resource_type = None + self.sku = sku + self.capacity = capacity + + +class IotHubSkuDescriptionListResult(_serialization.Model): + """The JSON-serialized array of IotHubSkuDescription objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuDescription] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuDescription] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubSkuInfo(_serialization.Model): + """Information about the SKU of the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". + :vartype name: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSku + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and + "Basic". + :vartype tier: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuTier + :ivar capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :vartype capacity: int + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + } + + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs): + """ + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSku + :keyword capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :paramtype capacity: int + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + self.capacity = capacity + + +class IpFilterRule(_serialization.Model): + """The IP filter rules for the IoT hub. + + All required parameters must be populated in order to send to Azure. + + :ivar filter_name: The name of the IP filter rule. Required. + :vartype filter_name: str + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". + :vartype action: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.IpFilterActionType + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :vartype ip_mask: str + """ + + _validation = { + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, + } + + _attribute_map = { + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, + } + + def __init__(self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs): + """ + :keyword filter_name: The name of the IP filter rule. Required. + :paramtype filter_name: str + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.IpFilterActionType + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :paramtype ip_mask: str + """ + super().__init__(**kwargs) + self.filter_name = filter_name + self.action = action + self.ip_mask = ip_mask + + +class JobResponse(_serialization.Model): + """The properties of the Job Response object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar job_id: The job identifier. + :vartype job_id: str + :ivar start_time_utc: The start time of the job. + :vartype start_time_utc: ~datetime.datetime + :ivar end_time_utc: The time the job stopped processing. + :vartype end_time_utc: ~datetime.datetime + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", and "firmwareUpdate". + :vartype type: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.JobType + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". + :vartype status: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.JobStatus + :ivar failure_reason: If status == failed, this string containing the reason for the failure. + :vartype failure_reason: str + :ivar status_message: The status message for the job. + :vartype status_message: str + :ivar parent_job_id: The job identifier of the parent job, if any. + :vartype parent_job_id: str + """ + + _validation = { + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.job_id = None + self.start_time_utc = None + self.end_time_utc = None + self.type = None + self.status = None + self.failure_reason = None + self.status_message = None + self.parent_job_id = None + + +class JobResponseListResult(_serialization.Model): + """The JSON-serialized array of JobResponse objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class KeyVaultKeyProperties(_serialization.Model): + """The properties of the KeyVault key. + + :ivar key_identifier: The identifier of the key. + :vartype key_identifier: str + :ivar identity: Managed identity properties of KeyVault Key. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + """ + + _attribute_map = { + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + } + + def __init__( + self, *, key_identifier: Optional[str] = None, identity: Optional["_models.ManagedIdentity"] = None, **kwargs + ): + """ + :keyword key_identifier: The identifier of the key. + :paramtype key_identifier: str + :keyword identity: Managed identity properties of KeyVault Key. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + """ + super().__init__(**kwargs) + self.key_identifier = key_identifier + self.identity = identity + + +class ManagedIdentity(_serialization.Model): + """The properties of the Managed identity. + + :ivar user_assigned_identity: The user assigned identity. + :vartype user_assigned_identity: str + """ + + _attribute_map = { + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + } + + def __init__(self, *, user_assigned_identity: Optional[str] = None, **kwargs): + """ + :keyword user_assigned_identity: The user assigned identity. + :paramtype user_assigned_identity: str + """ + super().__init__(**kwargs) + self.user_assigned_identity = user_assigned_identity + + +class MatchedRoute(_serialization.Model): + """Routes that matched. + + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "RouteProperties"}, + } + + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class MessagingEndpointProperties(_serialization.Model): + """The properties of the messaging endpoints used by this IoT hub. + + :ivar lock_duration_as_iso8601: The lock duration. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype lock_duration_as_iso8601: ~datetime.timedelta + :ivar ttl_as_iso8601: The period of time for which a message is available to consume before it + is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype ttl_as_iso8601: ~datetime.timedelta + :ivar max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype max_delivery_count: int + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + } + + def __init__( + self, + *, + lock_duration_as_iso8601: Optional[datetime.timedelta] = None, + ttl_as_iso8601: Optional[datetime.timedelta] = None, + max_delivery_count: Optional[int] = None, + **kwargs + ): + """ + :keyword lock_duration_as_iso8601: The lock duration. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype lock_duration_as_iso8601: ~datetime.timedelta + :keyword ttl_as_iso8601: The period of time for which a message is available to consume before + it is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype ttl_as_iso8601: ~datetime.timedelta + :keyword max_delivery_count: The number of times the IoT hub attempts to deliver a message. + See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype max_delivery_count: int + """ + super().__init__(**kwargs) + self.lock_duration_as_iso8601 = lock_duration_as_iso8601 + self.ttl_as_iso8601 = ttl_as_iso8601 + self.max_delivery_count = max_delivery_count + + +class Name(_serialization.Model): + """Name of Iot Hub type. + + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ + super().__init__(**kwargs) + self.value = value + self.localized_value = localized_value + + +class NetworkRuleSetIpRule(_serialization.Model): + """IP Rule to be applied as part of Network Rule Set. + + All required parameters must be populated in order to send to Azure. + + :ivar filter_name: Name of the IP filter rule. Required. + :vartype filter_name: str + :ivar action: IP Filter Action. "Allow" + :vartype action: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.NetworkRuleIPAction + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :vartype ip_mask: str + """ + + _validation = { + "filter_name": {"required": True}, + "ip_mask": {"required": True}, + } + + _attribute_map = { + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, + } + + def __init__( + self, *, filter_name: str, ip_mask: str, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs + ): + """ + :keyword filter_name: Name of the IP filter rule. Required. + :paramtype filter_name: str + :keyword action: IP Filter Action. "Allow" + :paramtype action: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.NetworkRuleIPAction + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :paramtype ip_mask: str + """ + super().__init__(**kwargs) + self.filter_name = filter_name + self.action = action + self.ip_mask = ip_mask + + +class NetworkRuleSetProperties(_serialization.Model): + """Network Rule Set Properties of IotHub. + + All required parameters must be populated in order to send to Azure. + + :ivar default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". + :vartype default_action: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.DefaultAction + :ivar apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied to + BuiltIn EventHub EndPoint of IotHub. Required. + :vartype apply_to_built_in_event_hub_endpoint: bool + :ivar ip_rules: List of IP Rules. Required. + :vartype ip_rules: list[~azure.mgmt.iothub.v2022_04_30_preview.models.NetworkRuleSetIpRule] + """ + + _validation = { + "apply_to_built_in_event_hub_endpoint": {"required": True}, + "ip_rules": {"required": True}, + } + + _attribute_map = { + "default_action": {"key": "defaultAction", "type": "str"}, + "apply_to_built_in_event_hub_endpoint": {"key": "applyToBuiltInEventHubEndpoint", "type": "bool"}, + "ip_rules": {"key": "ipRules", "type": "[NetworkRuleSetIpRule]"}, + } + + def __init__( + self, + *, + apply_to_built_in_event_hub_endpoint: bool, + ip_rules: List["_models.NetworkRuleSetIpRule"], + default_action: Union[str, "_models.DefaultAction"] = "Deny", + **kwargs + ): + """ + :keyword default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". + :paramtype default_action: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.DefaultAction + :keyword apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied + to BuiltIn EventHub EndPoint of IotHub. Required. + :paramtype apply_to_built_in_event_hub_endpoint: bool + :keyword ip_rules: List of IP Rules. Required. + :paramtype ip_rules: list[~azure.mgmt.iothub.v2022_04_30_preview.models.NetworkRuleSetIpRule] + """ + super().__init__(**kwargs) + self.default_action = default_action + self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint + self.ip_rules = ip_rules + + +class Operation(_serialization.Model): + """IoT Hub REST API operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2022_04_30_preview.models.OperationDisplay + """ + + _validation = { + "name": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2022_04_30_preview.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.display = display + + +class OperationDisplay(_serialization.Model): + """The object that represents the operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Service provider: Microsoft Devices. + :vartype provider: str + :ivar resource: Resource Type: IotHubs. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationInputs(_serialization.Model): + """Input values. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the IoT hub to check. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: The name of the IoT hub to check. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class OperationListResult(_serialization.Model): + """Result of the request to list IoT Hub operations. It contains a list of operations and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of IoT Hub operations supported by the Microsoft.Devices resource provider. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PrivateEndpoint(_serialization.Model): + """The private endpoint property of a private endpoint connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource identifier. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(_serialization.Model): + """The private endpoint connection of an IotHub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar properties: The properties of a private endpoint connection. Required. + :vartype properties: + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnectionProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, + } + + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs): + """ + :keyword properties: The properties of a private endpoint connection. Required. + :paramtype properties: + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnectionProperties + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class PrivateEndpointConnectionProperties(_serialization.Model): + """The properties of a private endpoint connection. + + All required parameters must be populated in order to send to Azure. + + :ivar private_endpoint: The private endpoint property of a private endpoint connection. + :vartype private_endpoint: ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpoint + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateLinkServiceConnectionState + """ + + _validation = { + "private_link_service_connection_state": {"required": True}, + } + + _attribute_map = { + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + } + + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + **kwargs + ): + """ + :keyword private_endpoint: The private endpoint property of a private endpoint connection. + :paramtype private_endpoint: ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpoint + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. + :paramtype private_link_service_connection_state: + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + + +class PrivateLinkResources(_serialization.Model): + """The available private link resources for an IotHub. + + :ivar value: The list of available private link resources for an IotHub. + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.GroupIdInformation] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GroupIdInformation]"}, + } + + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs): + """ + :keyword value: The list of available private link resources for an IotHub. + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.GroupIdInformation] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """The current state of a private endpoint connection. + + All required parameters must be populated in order to send to Azure. + + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". + :vartype status: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateLinkServiceConnectionStatus + :ivar description: The description for the current state of a private endpoint connection. + Required. + :vartype description: str + :ivar actions_required: Actions required for a private endpoint connection. + :vartype actions_required: str + """ + + _validation = { + "status": {"required": True}, + "description": {"required": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], + description: str, + actions_required: Optional[str] = None, + **kwargs + ): + """ + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". + :paramtype status: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateLinkServiceConnectionStatus + :keyword description: The description for the current state of a private endpoint connection. + Required. + :paramtype description: str + :keyword actions_required: Actions required for a private endpoint connection. + :paramtype actions_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class RegistryStatistics(_serialization.Model): + """Identity registry statistics. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar total_device_count: The total count of devices in the identity registry. + :vartype total_device_count: int + :ivar enabled_device_count: The count of enabled devices in the identity registry. + :vartype enabled_device_count: int + :ivar disabled_device_count: The count of disabled devices in the identity registry. + :vartype disabled_device_count: int + """ + + _validation = { + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, + } + + _attribute_map = { + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.total_device_count = None + self.enabled_device_count = None + self.disabled_device_count = None + + +class RootCertificateProperties(_serialization.Model): + """This property store root certificate related information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar enable_root_certificate_v2: This property when set to true, hub will use G2 cert; while + it's set to false, hub uses Baltimore Cert. + :vartype enable_root_certificate_v2: bool + :ivar last_updated_time_utc: the last update time to root certificate flag. + :vartype last_updated_time_utc: ~datetime.datetime + """ + + _validation = { + "last_updated_time_utc": {"readonly": True}, + } + + _attribute_map = { + "enable_root_certificate_v2": {"key": "enableRootCertificateV2", "type": "bool"}, + "last_updated_time_utc": {"key": "lastUpdatedTimeUtc", "type": "iso-8601"}, + } + + def __init__(self, *, enable_root_certificate_v2: Optional[bool] = None, **kwargs): + """ + :keyword enable_root_certificate_v2: This property when set to true, hub will use G2 cert; + while it's set to false, hub uses Baltimore Cert. + :paramtype enable_root_certificate_v2: bool + """ + super().__init__(**kwargs) + self.enable_root_certificate_v2 = enable_root_certificate_v2 + self.last_updated_time_utc = None + + +class RouteCompilationError(_serialization.Model): + """Compilation error when evaluating route. + + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Known values are: "error" and "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteErrorRange + """ + + _attribute_map = { + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, + **kwargs + ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Known values are: "error" and "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteErrorRange + """ + super().__init__(**kwargs) + self.message = message + self.severity = severity + self.location = location + + +class RouteErrorPosition(_serialization.Model): + """Position where the route error happened. + + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int + """ + + _attribute_map = { + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, + } + + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ + super().__init__(**kwargs) + self.line = line + self.column = column + + +class RouteErrorRange(_serialization.Model): + """Range of route errors. + + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteErrorPosition + """ + + _attribute_map = { + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, + } + + def __init__( + self, + *, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, + **kwargs + ): + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteErrorPosition + """ + super().__init__(**kwargs) + self.start = start + self.end = end + + +class RouteProperties(_serialization.Model): + """The properties of a routing rule that your IoT hub uses to route messages to endpoints. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. + :vartype name: str + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :vartype source: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingSource + :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is + provided, it evaluates to true by default. For grammar, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :vartype condition: str + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. + :vartype endpoint_names: list[str] + :ivar is_enabled: Used to specify whether a route is enabled. Required. + :vartype is_enabled: bool + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + source: Union[str, "_models.RoutingSource"], + endpoint_names: List[str], + is_enabled: bool, + condition: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. + :paramtype name: str + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :paramtype source: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingSource + :keyword condition: The condition that is evaluated to apply the routing rule. If no condition + is provided, it evaluates to true by default. For grammar, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :paramtype condition: str + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Used to specify whether a route is enabled. Required. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.name = name + self.source = source + self.condition = condition + self.endpoint_names = endpoint_names + self.is_enabled = is_enabled + + +class RoutingCosmosDBSqlApiProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties related to a cosmos DB sql collection endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar id: Id of the cosmos DB sql collection endpoint. + :vartype id: str + :ivar subscription_id: The subscription identifier of the cosmos DB account. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the cosmos DB account. + :vartype resource_group: str + :ivar endpoint_uri: The url of the cosmos DB account. It must include the protocol https://. + Required. + :vartype endpoint_uri: str + :ivar authentication_type: Method used to authenticate against the cosmos DB sql collection + endpoint. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing cosmos DB collection endpoint. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :ivar primary_key: The primary key of the cosmos DB account. + :vartype primary_key: str + :ivar secondary_key: The secondary key of the cosmos DB account. + :vartype secondary_key: str + :ivar database_name: The name of the cosmos DB database in the cosmos DB account. Required. + :vartype database_name: str + :ivar collection_name: The name of the cosmos DB sql collection in the cosmos DB database. + Required. + :vartype collection_name: str + :ivar partition_key_name: The name of the partition key associated with this cosmos DB sql + collection if one exists. This is an optional parameter. + :vartype partition_key_name: str + :ivar partition_key_template: The template for generating a synthetic partition key value for + use with this cosmos DB sql collection. The template must include at least one of the following + placeholders: {iothub}, {deviceid}, {DD}, {MM}, and {YYYY}. Any one placeholder may be + specified at most once, but order and non-placeholder components are arbitrary. This parameter + is only required if PartitionKeyName is specified. + :vartype partition_key_template: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "endpoint_uri": {"required": True}, + "database_name": {"required": True}, + "collection_name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + "collection_name": {"key": "collectionName", "type": "str"}, + "partition_key_name": {"key": "partitionKeyName", "type": "str"}, + "partition_key_template": {"key": "partitionKeyTemplate", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + endpoint_uri: str, + database_name: str, + collection_name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + partition_key_name: Optional[str] = None, + partition_key_template: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword id: Id of the cosmos DB sql collection endpoint. + :paramtype id: str + :keyword subscription_id: The subscription identifier of the cosmos DB account. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the cosmos DB account. + :paramtype resource_group: str + :keyword endpoint_uri: The url of the cosmos DB account. It must include the protocol https://. + Required. + :paramtype endpoint_uri: str + :keyword authentication_type: Method used to authenticate against the cosmos DB sql collection + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing cosmos DB collection endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :keyword primary_key: The primary key of the cosmos DB account. + :paramtype primary_key: str + :keyword secondary_key: The secondary key of the cosmos DB account. + :paramtype secondary_key: str + :keyword database_name: The name of the cosmos DB database in the cosmos DB account. Required. + :paramtype database_name: str + :keyword collection_name: The name of the cosmos DB sql collection in the cosmos DB database. + Required. + :paramtype collection_name: str + :keyword partition_key_name: The name of the partition key associated with this cosmos DB sql + collection if one exists. This is an optional parameter. + :paramtype partition_key_name: str + :keyword partition_key_template: The template for generating a synthetic partition key value + for use with this cosmos DB sql collection. The template must include at least one of the + following placeholders: {iothub}, {deviceid}, {DD}, {MM}, and {YYYY}. Any one placeholder may + be specified at most once, but order and non-placeholder components are arbitrary. This + parameter is only required if PartitionKeyName is specified. + :paramtype partition_key_template: str + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.subscription_id = subscription_id + self.resource_group = resource_group + self.endpoint_uri = endpoint_uri + self.authentication_type = authentication_type + self.identity = identity + self.primary_key = primary_key + self.secondary_key = secondary_key + self.database_name = database_name + self.collection_name = collection_name + self.partition_key_name = partition_key_name + self.partition_key_template = partition_key_template + + +class RoutingEndpoints(_serialization.Model): + """The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. + + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + messages to, based on the routing rules. + :vartype service_bus_queues: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingServiceBusQueueEndpointProperties] + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + messages to, based on the routing rules. + :vartype service_bus_topics: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingServiceBusTopicEndpointProperties] + :ivar event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + the routing rules. This list does not include the built-in Event Hubs endpoint. + :vartype event_hubs: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages + to, based on the routing rules. + :vartype storage_containers: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingStorageContainerProperties] + :ivar cosmos_db_sql_collections: The list of Cosmos DB collection endpoints that IoT hub routes + messages to, based on the routing rules. + :vartype cosmos_db_sql_collections: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingCosmosDBSqlApiProperties] + """ + + _attribute_map = { + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, + "cosmos_db_sql_collections": {"key": "cosmosDBSqlCollections", "type": "[RoutingCosmosDBSqlApiProperties]"}, + } + + def __init__( + self, + *, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, + cosmos_db_sql_collections: Optional[List["_models.RoutingCosmosDBSqlApiProperties"]] = None, + **kwargs + ): + """ + :keyword service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + messages to, based on the routing rules. + :paramtype service_bus_queues: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingServiceBusQueueEndpointProperties] + :keyword service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes + the messages to, based on the routing rules. + :paramtype service_bus_topics: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingServiceBusTopicEndpointProperties] + :keyword event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + the routing rules. This list does not include the built-in Event Hubs endpoint. + :paramtype event_hubs: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingEventHubProperties] + :keyword storage_containers: The list of storage container endpoints that IoT hub routes + messages to, based on the routing rules. + :paramtype storage_containers: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingStorageContainerProperties] + :keyword cosmos_db_sql_collections: The list of Cosmos DB collection endpoints that IoT hub + routes messages to, based on the routing rules. + :paramtype cosmos_db_sql_collections: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingCosmosDBSqlApiProperties] + """ + super().__init__(**kwargs) + self.service_bus_queues = service_bus_queues + self.service_bus_topics = service_bus_topics + self.event_hubs = event_hubs + self.storage_containers = storage_containers + self.cosmos_db_sql_collections = cosmos_db_sql_collections + + +class RoutingEventHubProperties(_serialization.Model): + """The properties related to an event hub endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the event hub endpoint. + :vartype id: str + :ivar connection_string: The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. + :vartype endpoint_uri: str + :ivar entity_path: Event hub name on the event hub namespace. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing event hub endpoint. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the event hub endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the event hub endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Id of the event hub endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Event hub name on the event hub namespace. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing event hub endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the event hub endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the event hub endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingMessage(_serialization.Model): + """Routing message. + + :ivar body: Body of routing message. + :vartype body: str + :ivar app_properties: App properties. + :vartype app_properties: dict[str, str] + :ivar system_properties: System properties. + :vartype system_properties: dict[str, str] + """ + + _attribute_map = { + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, + } + + def __init__( + self, + *, + body: Optional[str] = None, + app_properties: Optional[Dict[str, str]] = None, + system_properties: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword body: Body of routing message. + :paramtype body: str + :keyword app_properties: App properties. + :paramtype app_properties: dict[str, str] + :keyword system_properties: System properties. + :paramtype system_properties: dict[str, str] + """ + super().__init__(**kwargs) + self.body = body + self.app_properties = app_properties + self.system_properties = system_properties + + +class RoutingProperties(_serialization.Model): + """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + + :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes + messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all + endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types + for free hubs. + :vartype endpoints: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingEndpoints + :ivar routes: The list of user-provided routing rules that the IoT hub uses to route messages + to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid hubs and + a maximum of 5 routing rules are allowed for free hubs. + :vartype routes: list[~azure.mgmt.iothub.v2022_04_30_preview.models.RouteProperties] + :ivar fallback_route: The properties of the route that is used as a fall-back route when none + of the conditions specified in the 'routes' section are met. This is an optional parameter. + When this property is not set, the messages which do not meet any of the conditions specified + in the 'routes' section get routed to the built-in eventhub endpoint. + :vartype fallback_route: ~azure.mgmt.iothub.v2022_04_30_preview.models.FallbackRouteProperties + :ivar enrichments: The list of user-provided enrichments that the IoT hub applies to messages + to be delivered to built-in and custom endpoints. See: https://aka.ms/telemetryoneventgrid. + :vartype enrichments: list[~azure.mgmt.iothub.v2022_04_30_preview.models.EnrichmentProperties] + """ + + _attribute_map = { + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, + } + + def __init__( + self, + *, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, + **kwargs + ): + """ + :keyword endpoints: The properties related to the custom endpoints to which your IoT hub routes + messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all + endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types + for free hubs. + :paramtype endpoints: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingEndpoints + :keyword routes: The list of user-provided routing rules that the IoT hub uses to route + messages to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid + hubs and a maximum of 5 routing rules are allowed for free hubs. + :paramtype routes: list[~azure.mgmt.iothub.v2022_04_30_preview.models.RouteProperties] + :keyword fallback_route: The properties of the route that is used as a fall-back route when + none of the conditions specified in the 'routes' section are met. This is an optional + parameter. When this property is not set, the messages which do not meet any of the conditions + specified in the 'routes' section get routed to the built-in eventhub endpoint. + :paramtype fallback_route: + ~azure.mgmt.iothub.v2022_04_30_preview.models.FallbackRouteProperties + :keyword enrichments: The list of user-provided enrichments that the IoT hub applies to + messages to be delivered to built-in and custom endpoints. See: + https://aka.ms/telemetryoneventgrid. + :paramtype enrichments: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.EnrichmentProperties] + """ + super().__init__(**kwargs) + self.endpoints = endpoints + self.routes = routes + self.fallback_route = fallback_route + self.enrichments = enrichments + + +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): + """The properties related to service bus queue endpoint types. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the service bus queue endpoint. + :vartype id: str + :ivar connection_string: The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + sb://. + :vartype endpoint_uri: str + :ivar entity_path: Queue name on the service bus namespace. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the service bus queue endpoint. + Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus queue endpoint. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the service bus queue endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the service bus queue endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Id of the service bus queue endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Queue name on the service bus namespace. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the service bus queue + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus queue endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the service bus queue endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the service bus queue endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): + """The properties related to service bus topic endpoint types. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the service bus topic endpoint. + :vartype id: str + :ivar connection_string: The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + sb://. + :vartype endpoint_uri: str + :ivar entity_path: Queue name on the service bus topic. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the service bus topic endpoint. + Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus topic endpoint. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the service bus topic endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the service bus topic endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Id of the service bus topic endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Queue name on the service bus topic. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the service bus topic + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus topic endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the service bus topic endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the service bus topic endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingStorageContainerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties related to a storage container endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the storage container endpoint. + :vartype id: str + :ivar connection_string: The connection string of the storage account. + :vartype connection_string: str + :ivar endpoint_uri: The url of the storage endpoint. It must include the protocol https://. + :vartype endpoint_uri: str + :ivar authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing storage endpoint. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the storage account. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the storage account. + :vartype resource_group: str + :ivar container_name: The name of storage container in the storage account. Required. + :vartype container_name: str + :ivar file_name_format: File name format for the blob. Default format is + {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be + reordered. + :vartype file_name_format: str + :ivar batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + should be between 60 and 720 seconds. Default value is 300 seconds. + :vartype batch_frequency_in_seconds: int + :ivar max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). + :vartype max_chunk_size_in_bytes: int + :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". + :vartype encoding: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingStorageContainerPropertiesEncoding + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + container_name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + file_name_format: Optional[str] = None, + batch_frequency_in_seconds: Optional[int] = None, + max_chunk_size_in_bytes: Optional[int] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, + **kwargs + ): + """ + :keyword id: Id of the storage container endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the storage account. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the storage endpoint. It must include the protocol https://. + :paramtype endpoint_uri: str + :keyword authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing storage endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the storage account. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the storage account. + :paramtype resource_group: str + :keyword container_name: The name of storage container in the storage account. Required. + :paramtype container_name: str + :keyword file_name_format: File name format for the blob. Default format is + {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be + reordered. + :paramtype file_name_format: str + :keyword batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + should be between 60 and 720 seconds. Default value is 300 seconds. + :paramtype batch_frequency_in_seconds: int + :keyword max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. + Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). + :paramtype max_chunk_size_in_bytes: int + :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingStorageContainerPropertiesEncoding + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + self.container_name = container_name + self.file_name_format = file_name_format + self.batch_frequency_in_seconds = batch_frequency_in_seconds + self.max_chunk_size_in_bytes = max_chunk_size_in_bytes + self.encoding = encoding + + +class RoutingTwin(_serialization.Model): + """Twin reference input parameter. This is an optional parameter. + + :ivar tags: Twin Tags. + :vartype tags: JSON + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingTwinProperties + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, + } + + def __init__( + self, *, tags: Optional[JSON] = None, properties: Optional["_models.RoutingTwinProperties"] = None, **kwargs + ): + """ + :keyword tags: Twin Tags. + :paramtype tags: JSON + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingTwinProperties + """ + super().__init__(**kwargs) + self.tags = tags + self.properties = properties + + +class RoutingTwinProperties(_serialization.Model): + """RoutingTwinProperties. + + :ivar desired: Twin desired properties. + :vartype desired: JSON + :ivar reported: Twin desired properties. + :vartype reported: JSON + """ + + _attribute_map = { + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, + } + + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs): + """ + :keyword desired: Twin desired properties. + :paramtype desired: JSON + :keyword reported: Twin desired properties. + :paramtype reported: JSON + """ + super().__init__(**kwargs) + self.desired = desired + self.reported = reported + + +class SharedAccessSignatureAuthorizationRule(_serialization.Model): + """The properties of an IoT hub shared access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar key_name: The name of the shared access policy. Required. + :vartype key_name: str + :ivar primary_key: The primary key. + :vartype primary_key: str + :ivar secondary_key: The secondary key. + :vartype secondary_key: str + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :vartype rights: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.AccessRights + """ + + _validation = { + "key_name": {"required": True}, + "rights": {"required": True}, + } + + _attribute_map = { + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, + } + + def __init__( + self, + *, + key_name: str, + rights: Union[str, "_models.AccessRights"], + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + **kwargs + ): + """ + :keyword key_name: The name of the shared access policy. Required. + :paramtype key_name: str + :keyword primary_key: The primary key. + :paramtype primary_key: str + :keyword secondary_key: The secondary key. + :paramtype secondary_key: str + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.AccessRights + """ + super().__init__(**kwargs) + self.key_name = key_name + self.primary_key = primary_key + self.secondary_key = secondary_key + self.rights = rights + + +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): + """The list of shared access policies with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.SharedAccessSignatureAuthorizationRule] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.SharedAccessSignatureAuthorizationRule] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class StorageEndpointProperties(_serialization.Model): + """The properties of the Azure Storage endpoint for file upload. + + All required parameters must be populated in order to send to Azure. + + :ivar sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. + :vartype connection_string: str + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. + :vartype container_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for file upload. + :vartype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + """ + + _validation = { + "connection_string": {"required": True}, + "container_name": {"required": True}, + } + + _attribute_map = { + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + } + + def __init__( + self, + *, + connection_string: str, + container_name: str, + sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + **kwargs + ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. + :paramtype connection_string: str + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. + :paramtype container_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for file upload. + :paramtype identity: ~azure.mgmt.iothub.v2022_04_30_preview.models.ManagedIdentity + """ + super().__init__(**kwargs) + self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 + self.connection_string = connection_string + self.container_name = container_name + self.authentication_type = authentication_type + self.identity = identity + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.iothub.v2022_04_30_preview.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TagsResource(_serialization.Model): + """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class TestAllRoutesInput(_serialization.Model): + """Input for testing all routes. + + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DigitalTwinChangeEvents", "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :vartype routing_source: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingTwin + """ + + _attribute_map = { + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, + } + + def __init__( + self, + *, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, + **kwargs + ): + """ + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DigitalTwinChangeEvents", "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingTwin + """ + super().__init__(**kwargs) + self.routing_source = routing_source + self.message = message + self.twin = twin + + +class TestAllRoutesResult(_serialization.Model): + """Result of testing all routes. + + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2022_04_30_preview.models.MatchedRoute] + """ + + _attribute_map = { + "routes": {"key": "routes", "type": "[MatchedRoute]"}, + } + + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2022_04_30_preview.models.MatchedRoute] + """ + super().__init__(**kwargs) + self.routes = routes + + +class TestRouteInput(_serialization.Model): + """Input for testing route. + + All required parameters must be populated in order to send to Azure. + + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingMessage + :ivar route: Route properties. Required. + :vartype route: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingTwin + """ + + _validation = { + "route": {"required": True}, + } + + _attribute_map = { + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, + } + + def __init__( + self, + *, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, + **kwargs + ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingMessage + :keyword route: Route properties. Required. + :paramtype route: ~azure.mgmt.iothub.v2022_04_30_preview.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2022_04_30_preview.models.RoutingTwin + """ + super().__init__(**kwargs) + self.message = message + self.route = route + self.twin = twin + + +class TestRouteResult(_serialization.Model): + """Result of testing one route. + + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". + :vartype result: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteResultDetails + """ + + _attribute_map = { + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, + } + + def __init__( + self, + *, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, + **kwargs + ): + """ + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". + :paramtype result: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteResultDetails + """ + super().__init__(**kwargs) + self.result = result + self.details = details + + +class TestRouteResultDetails(_serialization.Model): + """Detailed result of testing a route. + + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RouteCompilationError] + """ + + _attribute_map = { + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, + } + + def __init__(self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2022_04_30_preview.models.RouteCompilationError] + """ + super().__init__(**kwargs) + self.compilation_errors = compilation_errors + + +class UserSubscriptionQuota(_serialization.Model): + """User subscription quota response. + + :ivar id: IotHub type id. + :vartype id: str + :ivar type: Response type. + :vartype type: str + :ivar unit: Unit of IotHub type. + :vartype unit: str + :ivar current_value: Current number of IotHub type. + :vartype current_value: int + :ivar limit: Numerical limit on IotHub type. + :vartype limit: int + :ivar name: IotHub type. + :vartype name: ~azure.mgmt.iothub.v2022_04_30_preview.models.Name + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + unit: Optional[str] = None, + current_value: Optional[int] = None, + limit: Optional[int] = None, + name: Optional["_models.Name"] = None, + **kwargs + ): + """ + :keyword id: IotHub type id. + :paramtype id: str + :keyword type: Response type. + :paramtype type: str + :keyword unit: Unit of IotHub type. + :paramtype unit: str + :keyword current_value: Current number of IotHub type. + :paramtype current_value: int + :keyword limit: Numerical limit on IotHub type. + :paramtype limit: int + :keyword name: IotHub type. + :paramtype name: ~azure.mgmt.iothub.v2022_04_30_preview.models.Name + """ + super().__init__(**kwargs) + self.id = id + self.type = type + self.unit = unit + self.current_value = current_value + self.limit = limit + self.name = name + + +class UserSubscriptionQuotaListResult(_serialization.Model): + """Json-serialized array of User subscription quota response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.UserSubscriptionQuota] + :ivar next_link: + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2022_04_30_preview.models.UserSubscriptionQuota] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/__init__.py new file mode 100644 index 000000000000..901e21834b4d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/__init__.py @@ -0,0 +1,31 @@ +# 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 ._operations import Operations +from ._iot_hub_resource_operations import IotHubResourceOperations +from ._resource_provider_common_operations import ResourceProviderCommonOperations +from ._certificates_operations import CertificatesOperations +from ._iot_hub_operations import IotHubOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_certificates_operations.py new file mode 100644 index 000000000000..038dca3da852 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_certificates_operations.py @@ -0,0 +1,863 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_iot_hub_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_generate_verification_code_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_verify_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.IotHubClient`'s + :attr:`certificates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_iot_hub( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: + """Get the certificate list. + + Returns the list of certificates. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateListDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateListDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] + + request = build_list_by_iot_hub_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateListDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_iot_hub.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: + """Get the certificate. + + Returns the certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: Union[_models.CertificateDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. + :type certificate_description: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription or IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> None: + """Delete an X509 certificate. + + Deletes an existing X509 certificate or does nothing if it does not exist. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def generate_verification_code( + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: + """Generate verification code for proof of possession flow. + + Generates verification code for proof of possession flow. The verification code will be used to + generate a leaf certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateWithNonceDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateWithNonceDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateWithNonceDescription] + + request = build_generate_verification_code_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Is either a model type or a + IO type. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IO, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") + + request = build_verify_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + verify.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_operations.py new file mode 100644 index 000000000000..4d67512d95d7 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_operations.py @@ -0,0 +1,306 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.IotHubClient`'s + :attr:`iot_hub` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IO, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _manual_failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2022_04_30_preview.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Is either a model type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2022_04_30_preview.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._manual_failover_initial( # type: ignore + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + failover_input=failover_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_manual_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_resource_operations.py new file mode 100644 index 000000000000..0c1e9f0b522d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_resource_operations.py @@ -0,0 +1,3237 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_stats_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_valid_skus_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_event_hub_consumer_groups_request( + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_jobs_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_job_request( + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_quota_metrics_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_endpoint_health_request( + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_test_all_routes_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_test_route_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_keys_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_keys_for_key_name_request( + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_export_devices_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_import_devices_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.IotHubClient`'s + :attr:`iot_hub_resource` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: + """Get the non-security related metadata of an IoT hub. + + Get the non-security related metadata of an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IO, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a model type + or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription or + IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IO, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2022_04_30_preview.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + model type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2022_04_30_preview.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_tags=iot_hub_tags, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + def _delete_initial( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("ErrorDetails", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[LROPoller[_models.IotHubDescription], LROPoller[_models.ErrorDetails]]: + """Delete an IoT hub. + + Delete an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a subscription. + + Get all the IoT hubs in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a resource group. + + Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs"} # type: ignore + + @distributed_trace + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: + """Get the statistics from an IoT hub. + + Get the statistics from an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryStatistics or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.RegistryStatistics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistryStatistics] + + request = build_get_stats_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryStatistics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_stats.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats"} # type: ignore + + @distributed_trace + def get_valid_skus( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: + """Get the list of valid SKUs for an IoT hub. + + Get the list of valid SKUs for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubSkuDescription or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubSkuDescriptionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_valid_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus"} # type: ignore + + @distributed_trace + def list_event_hub_consumer_groups( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: + """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. + :type event_hub_endpoint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_event_hub_consumer_groups_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_event_hub_consumer_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups"} # type: ignore + + @distributed_trace + def get_event_hub_consumer_group( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to retrieve. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] + + request = build_get_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @overload + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a model type or a IO type. + Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventHubConsumerGroupInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IO, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @distributed_trace + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_event_hub_consumer_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}"} # type: ignore + + @distributed_trace + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: + """Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_jobs_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("JobResponseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_jobs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs"} # type: ignore + + @distributed_trace + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: + """Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param job_id: The job identifier. Required. + :type job_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + request = build_get_job_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_job.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}"} # type: ignore + + @distributed_trace + def get_quota_metrics( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: + """Get the quota metrics for an IoT hub. + + Get the quota metrics for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubQuotaMetricInfoListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_quota_metrics_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_quota_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics"} # type: ignore + + @distributed_trace + def get_endpoint_health( + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: + """Get the health for routing endpoints. + + Get the health for routing endpoints. + + :param resource_group_name: Required. + :type resource_group_name: str + :param iot_hub_name: Required. + :type iot_hub_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EndpointHealthDataListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_endpoint_health_request( + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_endpoint_health.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth"} # type: ignore + + @overload + def check_name_availability( + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2022_04_30_preview.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a model type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2022_04_30_preview.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotHubNameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IO, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability"} # type: ignore + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestAllRoutesResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") + + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_all_routes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall"} # type: ignore + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestRouteInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a model type or a IO type. Required. + :type input: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestRouteResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IO, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") + + request = build_test_route_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestRouteResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_route.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew"} # type: ignore + + @distributed_trace + def list_keys( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: + """Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_keys_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys"} # type: ignore + + @distributed_trace + def get_keys_for_key_name( + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: + """Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param key_name: The name of the shared access policy. Required. + :type key_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.SharedAccessSignatureAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRule] + + request = build_get_keys_for_key_name_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys"} # type: ignore + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2022_04_30_preview.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a model type or a IO type. Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2022_04_30_preview.models.ExportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IO, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") + + request = build_export_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices"} # type: ignore + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2022_04_30_preview.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a model type or a IO type. Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2022_04_30_preview.models.ImportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JobResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IO, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") + + request = build_import_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + import_devices.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_operations.py new file mode 100644 index 000000000000..7f7ecb87b2c6 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_operations.py @@ -0,0 +1,141 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.IotHubClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Lists all of the available IoT Hub REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2022_04_30_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..b0dd3777eb28 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,692 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: + """List private endpoint connections. + + List private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of PrivateEndpointConnection or the result of cls(response) + :rtype: list[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get private endpoint connection. + + Get private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + def _delete_initial( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Delete private endpoint connection. + + Delete private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..96d954bdfb29 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_link_resources_operations.py @@ -0,0 +1,233 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.IotHubClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: + """List private link resources. + + List private link resources for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResources or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.PrivateLinkResources + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: + """Get the specified private link resource. + + Get the specified private link resource for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param group_id: The name of the private link resource. Required. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupIdInformation or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.GroupIdInformation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GroupIdInformation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_resource_provider_common_operations.py new file mode 100644 index 000000000000..7f81da914c21 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_resource_provider_common_operations.py @@ -0,0 +1,127 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2022_04_30_preview.IotHubClient`'s + :attr:`resource_provider_common` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: + """Get the number of iot hubs in the subscription. + + Get the number of free and paid iot hubs in the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserSubscriptionQuotaListResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2022_04_30_preview.models.UserSubscriptionQuotaListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSubscriptionQuotaListResult] + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/py.typed b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file